28642023-01-30 23:47:49bencewokVideójátékgolangWrong answer 0/100129ms56172 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 answer28ms30268 KiB
2Wrong answer25ms30844 KiB
subtask20/10
3Accepted26ms30740 KiB
4Accepted26ms30956 KiB
5Accepted27ms31396 KiB
6Accepted25ms31420 KiB
7Wrong answer26ms31144 KiB
8Wrong answer24ms31612 KiB
9Accepted24ms31744 KiB
10Wrong answer27ms31804 KiB
11Wrong answer25ms32540 KiB
subtask30/20
12Wrong answer27ms32516 KiB
13Wrong answer26ms32136 KiB
14Wrong answer26ms32556 KiB
15Wrong answer27ms32584 KiB
16Wrong answer24ms33072 KiB
17Runtime error123ms55304 KiB
18Runtime error125ms55344 KiB
19Runtime error123ms54772 KiB
20Runtime error123ms54548 KiB
21Runtime error129ms54928 KiB
22Runtime error129ms54984 KiB
subtask40/30
23Runtime error129ms55076 KiB
24Runtime error128ms55276 KiB
25Runtime error126ms55376 KiB
26Runtime error129ms55236 KiB
27Runtime error128ms55328 KiB
28Runtime error128ms55060 KiB
29Runtime error125ms54396 KiB
30Runtime error129ms55440 KiB
31Runtime error123ms55016 KiB
subtask50/40
32Runtime error122ms55016 KiB
33Runtime error122ms55524 KiB
34Runtime error128ms56028 KiB
35Runtime error125ms56056 KiB
36Runtime error123ms55768 KiB
37Runtime error123ms56172 KiB
38Runtime error123ms55656 KiB
39Runtime error123ms55652 KiB
40Runtime error128ms55808 KiB
41Runtime error128ms55796 KiB