28672023-01-31 10:44:13mraronVideójátékgolangRuntime error 0/100722ms538528 KiB
package main

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

func inputFunc() func() []int {
    scanner := bufio.NewScanner(os.Stdin)
    return func() []int {
        var input string
        var output []int
        
        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() {
    input := inputFunc()
    
	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
1Accepted25ms29964 KiB
2Runtime error211ms538528 KiB
subtask20/10
3Runtime error216ms538080 KiB
4Runtime error261ms537396 KiB
5Runtime error263ms537508 KiB
6Runtime error129ms54084 KiB
7Runtime error125ms53916 KiB
8Accepted611ms259532 KiB
9Accepted27ms32388 KiB
10Runtime error722ms536616 KiB
11Runtime error250ms536640 KiB
subtask30/20
12Runtime error123ms54664 KiB
13Runtime error259ms72008 KiB
14Runtime error250ms536180 KiB
15Accepted27ms33216 KiB
16Accepted25ms33864 KiB
17Runtime error250ms535712 KiB
18Runtime error202ms535496 KiB
19Runtime error250ms535480 KiB
20Wrong answer28ms34936 KiB
21Wrong answer26ms35108 KiB
22Wrong answer23ms34648 KiB
subtask40/30
23Runtime error149ms64920 KiB
24Accepted107ms48960 KiB
25Runtime error372ms74308 KiB
26Runtime error305ms81860 KiB
27Runtime error298ms76212 KiB
28Runtime error194ms67884 KiB
29Wrong answer41ms43832 KiB
30Wrong answer41ms43704 KiB
31Wrong answer32ms38220 KiB
subtask50/40
32Wrong answer78ms75156 KiB
33Wrong answer665ms359508 KiB
34Runtime error621ms534708 KiB
35Runtime error361ms534624 KiB
36Runtime error428ms534720 KiB
37Runtime error381ms534672 KiB
38Wrong answer187ms95552 KiB
39Wrong answer224ms107300 KiB
40Wrong answer90ms74324 KiB
41Wrong answer112ms83428 KiB