28622023-01-30 23:41:14bencewokVideójátékgolangWrong answer 0/100129ms56484 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] = 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 answer25ms30036 KiB
2Wrong answer27ms30716 KiB
subtask20/10
3Accepted24ms30816 KiB
4Accepted27ms31148 KiB
5Accepted27ms31644 KiB
6Accepted26ms31664 KiB
7Wrong answer25ms31736 KiB
8Wrong answer23ms31964 KiB
9Accepted26ms32272 KiB
10Wrong answer25ms32652 KiB
11Wrong answer25ms32592 KiB
subtask30/20
12Wrong answer24ms33160 KiB
13Wrong answer25ms33092 KiB
14Wrong answer24ms33140 KiB
15Wrong answer21ms33092 KiB
16Wrong answer25ms33080 KiB
17Runtime error128ms55560 KiB
18Runtime error125ms55608 KiB
19Runtime error128ms55684 KiB
20Runtime error125ms55316 KiB
21Runtime error128ms55356 KiB
22Runtime error125ms55604 KiB
subtask40/30
23Runtime error128ms55016 KiB
24Runtime error123ms55404 KiB
25Runtime error128ms55940 KiB
26Runtime error128ms55636 KiB
27Runtime error128ms55612 KiB
28Runtime error129ms55844 KiB
29Runtime error125ms55440 KiB
30Runtime error123ms55840 KiB
31Runtime error123ms55496 KiB
subtask50/40
32Runtime error128ms55828 KiB
33Runtime error129ms56068 KiB
34Runtime error125ms56144 KiB
35Runtime error123ms55928 KiB
36Runtime error128ms56460 KiB
37Runtime error128ms56484 KiB
38Runtime error128ms55684 KiB
39Runtime error125ms56096 KiB
40Runtime error123ms56020 KiB
41Runtime error128ms56252 KiB