29842023-02-07 09:33:16lacitoVideójátékpypy3Time limit exceeded 0/1002.079s200892 KiB
from sys import stdin, stdout

def main():
    
    global hanop
    hanop = int(0)
    t = int(stdin.readline())
    n = int(stdin.readline())
    te_szuneted=[]
    hano_szunete=[]
    for i in range(0,n):
        te_szuneted.append(stdin.readline().split())
    m = int(stdin.readline())
    for j in range(m):
        hano_szunete.append(stdin.readline().split())
    #print(te_szuneted)
    #print(hano_szunete)
    opercek:int = 0
    tszam:int = 0
    te_szuneted = [[int(j) for j in i] for i in te_szuneted]
    hano_szunete = [[int(j) for j in i] for i in hano_szunete]
    #print(te_szuneted)
    #print(hano_szunete)
    def online(ido:int, hano_szunete_p) -> bool:
        global hanop
        try:
            while hano_szunete_p[hanop][1] < ido:
                hanop+=1
                if hanop>=len(hano_szunete_p):
                    return False
        except Exception:return False
        
        if hano_szunete_p[hanop][0] <= ido:
            return True
        else:
            #print(f"false, ido: {ido} ")
            return False
    for i in te_szuneted:
        for j in range(i[0],i[1]+1):
            #print("ido: "+str(j))
            tszam+=1
            if online(j,hano_szunete):
                tszam = 0
                #print(f"i: {i} j: {j}")
                opercek+=1
            if tszam==t:
                break
        tszam=0
    stdout.write(str(int(opercek)))
    return 0
main()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted48ms76732 KiB
2Accepted54ms85772 KiB
subtask20/10
3Accepted45ms77884 KiB
4Accepted54ms86268 KiB
5Accepted43ms77780 KiB
6Accepted56ms87168 KiB
7Accepted54ms87212 KiB
8Accepted57ms86828 KiB
9Accepted43ms78208 KiB
10Accepted54ms87328 KiB
11Time limit exceeded2.079s25704 KiB
subtask30/20
12Accepted48ms78912 KiB
13Accepted57ms88136 KiB
14Accepted990ms88260 KiB
15Accepted59ms88508 KiB
16Accepted59ms88780 KiB
17Accepted275ms89908 KiB
18Time limit exceeded2.078s27484 KiB
19Time limit exceeded2.055s27908 KiB
20Wrong answer64ms89876 KiB
21Wrong answer71ms91080 KiB
22Wrong answer57ms83676 KiB
subtask40/30
23Accepted112ms103052 KiB
24Accepted160ms129136 KiB
25Accepted282ms185444 KiB
26Accepted287ms200828 KiB
27Accepted319ms200892 KiB
28Accepted180ms136656 KiB
29Wrong answer119ms99044 KiB
30Wrong answer105ms99328 KiB
31Accepted90ms95792 KiB
subtask50/40
32Wrong answer115ms104100 KiB
33Accepted257ms132852 KiB
34Accepted1.172s171832 KiB
35Time limit exceeded2.075s79300 KiB
36Time limit exceeded2.051s85300 KiB
37Time limit exceeded2.028s85804 KiB
38Wrong answer203ms165300 KiB
39Wrong answer228ms180480 KiB
40Accepted118ms112124 KiB
41Wrong answer136ms124120 KiB