57372023-09-11 21:41:14KezdőÁruszállítás üres szakaszaipython3Runtime error 44/50365ms68824 KiB
from sys import stdin

def main():
    N, M = [int(i) for i in input().split()]
    aru = {}
    for i in range(M):
        b, k = [int(i) for i in stdin.readline().split()]
        if b not in aru:
            aru[b] = 1
        else:
            aru[b] += 1
        if k not in aru:
            aru[k] = -1
        else:
            aru[k] -= 1
    ar = sorted([[a,aru[a]] for a in aru])
    ##print(ar)
    cs = 0
    dbar = len(ar)
    db = 0
    if ar[0][0] > 1:
        db = 1
    for i in range(dbar):
        cs += ar[i][1]
    ##    print(ar[i],cs)
        if cs == 0 and ar[i][1] < 0 and ar[i][0] < N:
            db += 1
    print(db)

main()
SubtaskSumTestVerdictTimeMemory
base44/50
1Accepted0/018ms11180 KiB
2Runtime error0/0237ms68824 KiB
3Accepted2/217ms11740 KiB
4Accepted2/217ms11768 KiB
5Accepted2/217ms11420 KiB
6Accepted2/217ms11708 KiB
7Accepted2/217ms11400 KiB
8Accepted2/217ms11472 KiB
9Accepted2/217ms11932 KiB
10Accepted2/217ms11900 KiB
11Accepted2/217ms12308 KiB
12Accepted2/218ms12848 KiB
13Accepted3/339ms16512 KiB
14Accepted3/348ms17900 KiB
15Accepted3/335ms15816 KiB
16Accepted3/3194ms30720 KiB
17Accepted3/3197ms31292 KiB
18Accepted3/3226ms32972 KiB
19Accepted3/348ms18560 KiB
20Accepted3/352ms19488 KiB
21Time limit exceeded0/3365ms32600 KiB
22Runtime error0/3252ms67036 KiB