28632023-01-30 23:46:50bencewokVideójátékgolangWrong answer 0/100128ms56160 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++ {
		//fmt.Println(i, "1")
		if max < yBreaks[i] {
			max = yBreaks[i]
		}
	}

	for i := 1; i < len(aBreaks); i++ {
		//fmt.Println(i, "2")
		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
		}

		//fmt.Println(q, u, "3")

		charta[aBreaks[q]-u] = 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
		}

		//fmt.Println(q, u, "4")

		charty[yBreaks[q]-u] = 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++ {
		//fmt.Println(i, index, "5")

		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++ {
		//fmt.Println(i, "6")

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

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

	fmt.Println(output)
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer27ms30004 KiB
2Wrong answer26ms30212 KiB
subtask20/10
3Accepted24ms30860 KiB
4Accepted23ms30860 KiB
5Accepted21ms31472 KiB
6Accepted21ms31804 KiB
7Wrong answer25ms32084 KiB
8Wrong answer26ms32672 KiB
9Accepted24ms32600 KiB
10Wrong answer26ms32560 KiB
11Wrong answer25ms32480 KiB
subtask30/20
12Wrong answer24ms33068 KiB
13Wrong answer25ms33256 KiB
14Wrong answer25ms33156 KiB
15Wrong answer23ms32956 KiB
16Wrong answer21ms33044 KiB
17Runtime error122ms54908 KiB
18Runtime error122ms54920 KiB
19Runtime error122ms55168 KiB
20Runtime error128ms55812 KiB
21Runtime error128ms55988 KiB
22Runtime error125ms55764 KiB
subtask40/30
23Runtime error122ms56092 KiB
24Runtime error122ms56024 KiB
25Runtime error122ms55656 KiB
26Runtime error123ms55820 KiB
27Runtime error122ms54784 KiB
28Runtime error122ms55140 KiB
29Runtime error122ms55220 KiB
30Runtime error122ms55684 KiB
31Runtime error128ms55660 KiB
subtask50/40
32Runtime error125ms55928 KiB
33Runtime error128ms56160 KiB
34Runtime error125ms56064 KiB
35Runtime error122ms55764 KiB
36Runtime error123ms55788 KiB
37Runtime error123ms55900 KiB
38Runtime error122ms55736 KiB
39Runtime error128ms56072 KiB
40Runtime error125ms55952 KiB
41Runtime error123ms55936 KiB