28582023-01-30 15:34:20bencewokVideójátékgolangWrong answer 0/100128ms56540 KiB
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func input() []int {
	var input string
	var output []int

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	input = scanner.Text()

	inputSplit := strings.Split(input, " ")

	for i := 0; i < len(inputSplit); i++ {
		charInt, _ := strconv.Atoi(inputSplit[i])
		output = append(output, charInt)
	}

	return output
}

func main() {
	var aBreaks, yBreaks []int
	var boretime, boretimeNow, aLenght, yLenght, output int

	boretime = input()[0]

	aLenght = input()[0]

	for i := 0; i < aLenght; i++ {
		ln := input()
		aBreaks = append(aBreaks, ln[0])
		aBreaks = append(aBreaks, ln[1])
	}

	yLenght = input()[0]

	for i := 0; i < yLenght; i++ {
		ln := input()
		yBreaks = append(yBreaks, ln[0])
		yBreaks = append(yBreaks, ln[1])
	}


	//chart creation
	var max int

	for i := 1; i < len(yBreaks); i++ {
		if max < yBreaks[i] {
			max = yBreaks[i]
		}
	}

	for i := 1; i < len(aBreaks); i++ {
		if max < aBreaks[i] {
			max = aBreaks[i]
		}
	}
	charta := make([]int, max)
	charty := make([]int, max)

	q, u := 1, 0
	for {

		if q > len(aBreaks) {
			break
		}

		charta[aBreaks[q]-u-1] = 1

		if aBreaks[q]-u == aBreaks[q-1] {
			u = 0
			q = q + 2
		} else {
			u++
		}
		//fmt.Println(charta)
	}

	q, u = 1, 0
	for {
		if q > len(yBreaks) {
			break
		}

		charty[yBreaks[q]-u-1] = 1

		if yBreaks[q]-u == yBreaks[q-1] {
			u = 0
			q = q + 2
		} else {
			u++
		}
		//fmt.Println(charty)
	}

	var index int

	//fmt.Println(charta)
	//fmt.Println(charty)

	for i := 0; i < len(charta); i++ {
		if boretime == boretimeNow {
			index = i
			for charta[index] != 0 {
				charta[index] = 0
				index++
			}
			boretimeNow = 0
		}

		if charta[i] == 1 && charta[i] != charty[i] {
			boretimeNow++
		}

	}

	for i := 0; i < len(charta); i++ {
		if charta[i] == 1 && charta[i] == charty[i] {
			output++
		}
	}

	//fmt.Println(charta)
	//fmt.Println(charty)

	fmt.Println(output)
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer27ms29932 KiB
2Wrong answer26ms30396 KiB
subtask20/10
3Accepted28ms30912 KiB
4Accepted27ms31092 KiB
5Accepted25ms31160 KiB
6Accepted25ms31016 KiB
7Wrong answer26ms30832 KiB
8Wrong answer26ms31536 KiB
9Accepted25ms31196 KiB
10Wrong answer26ms31720 KiB
11Wrong answer24ms32072 KiB
subtask30/20
12Wrong answer25ms32048 KiB
13Wrong answer26ms32236 KiB
14Wrong answer24ms32572 KiB
15Wrong answer25ms32300 KiB
16Wrong answer25ms32336 KiB
17Runtime error128ms54468 KiB
18Runtime error125ms54752 KiB
19Runtime error128ms54536 KiB
20Runtime error128ms54924 KiB
21Runtime error125ms54724 KiB
22Runtime error128ms54360 KiB
subtask40/30
23Runtime error125ms54540 KiB
24Runtime error128ms54844 KiB
25Runtime error125ms55396 KiB
26Runtime error128ms55204 KiB
27Runtime error128ms55624 KiB
28Runtime error125ms55588 KiB
29Runtime error128ms55120 KiB
30Runtime error128ms55996 KiB
31Runtime error125ms55276 KiB
subtask50/40
32Runtime error128ms55844 KiB
33Runtime error125ms55576 KiB
34Runtime error123ms55744 KiB
35Runtime error128ms56036 KiB
36Runtime error123ms55876 KiB
37Runtime error122ms56016 KiB
38Runtime error128ms55772 KiB
39Runtime error128ms56540 KiB
40Runtime error125ms55968 KiB
41Runtime error122ms56492 KiB