Submission details
Task:Binge watching
Sender:aalto25b_004
Submission time:2025-09-10 16:26:22 +0300
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#10.04 sdetails
#20.04 sdetails
#30.04 sdetails
#40.84 sdetails
#50.36 sdetails
#60.67 sdetails
#70.04 sdetails
#80.04 sdetails
#90.04 sdetails

Code

def function(n, movies):
    movies.sort(key=lambda x: x[1])
    count = 0
    end_time = 0
    for movie in movies:
        if movie[0] >= end_time:
            print(movie[0], end_time)
            count += 1
            end_time = movie[1]
    return count


def main():
    # input :
    # 3
    # 3 5
    # 4 9
    # 5 8

    n = int(input())
    movies = []

    for _ in range(n):
        a, b = map(int, input().split())

        movies.append([a, b])


    result = function(n, movies)
    print(result)



if __name__ == "__main__":
    main()


Test details

Test 1

Verdict:

input
10
6 7
4 5
8 9
2 3
...

correct output
10

user output
1 0
2 2
3 3
4 4
5 5
...

Test 2

Verdict:

input
10
1 1000
1 1000
1 1000
1 1000
...

correct output
1

user output
1 0
1

Test 3

Verdict:

input
10
404 882
690 974
201 255
800 933
...

correct output
4

user output
201 0
457 255
699 601
832 804
4

Test 4

Verdict:

input
200000
177494 177495
157029 157030
6030 6031
15209 15210
...

correct output
200000

user output
1 0
2 2
3 3
4 4
5 5
...
Truncated

Test 5

Verdict:

input
200000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
...

correct output
1

user output
1 0
1

Test 6

Verdict:

input
200000
82334756 323555178
958182284 981100325
649818003 678160906
801994655 889397498
...

correct output
725

user output
722928 0
3340526 1399549
6322519 4902968
9369962 7160958
10582917 9384782
...
Truncated

Test 7

Verdict:

input
3
1 1000
2 3
5 6

correct output
2

user output
2 0
5 3
2

Test 8

Verdict:

input
3
3 4
5 6
7 8

correct output
3

user output
3 0
5 4
7 6
3

Test 9

Verdict:

input
2
1 2
3 4

correct output
2

user output
1 0
3 2
2