結果

問題 No.1557 Binary Variable
ユーザー ThetaTheta
提出日時 2024-04-16 12:05:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 473 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 97,816 KB
最終ジャッジ日時 2024-04-16 12:05:27
合計ジャッジ時間 16,655 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 205 ms
88,088 KB
testcase_01 AC 213 ms
91,112 KB
testcase_02 AC 43 ms
52,096 KB
testcase_03 AC 41 ms
51,968 KB
testcase_04 AC 298 ms
88,392 KB
testcase_05 AC 298 ms
89,144 KB
testcase_06 AC 280 ms
87,712 KB
testcase_07 AC 288 ms
87,572 KB
testcase_08 AC 346 ms
88,980 KB
testcase_09 AC 388 ms
88,592 KB
testcase_10 AC 392 ms
88,316 KB
testcase_11 AC 390 ms
88,820 KB
testcase_12 AC 371 ms
88,732 KB
testcase_13 AC 397 ms
88,564 KB
testcase_14 AC 428 ms
97,816 KB
testcase_15 AC 434 ms
88,560 KB
testcase_16 AC 412 ms
88,596 KB
testcase_17 AC 409 ms
88,472 KB
testcase_18 AC 434 ms
88,604 KB
testcase_19 AC 451 ms
95,640 KB
testcase_20 AC 446 ms
96,276 KB
testcase_21 AC 473 ms
96,400 KB
testcase_22 AC 450 ms
95,712 KB
testcase_23 AC 458 ms
96,916 KB
testcase_24 AC 468 ms
92,520 KB
testcase_25 AC 443 ms
93,320 KB
testcase_26 AC 466 ms
90,820 KB
testcase_27 AC 442 ms
90,544 KB
testcase_28 AC 433 ms
88,568 KB
testcase_29 AC 439 ms
88,412 KB
testcase_30 AC 417 ms
88,676 KB
testcase_31 AC 412 ms
88,540 KB
testcase_32 AC 443 ms
88,540 KB
testcase_33 AC 454 ms
96,924 KB
testcase_34 AC 40 ms
51,968 KB
testcase_35 AC 41 ms
52,224 KB
testcase_36 AC 41 ms
51,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N, M = map(int, input().split())
    regions = []
    for _ in range(M):
        L, R = map(int, input().split())
        regions.append((L - 1, R - 1))
    regions.sort(key=lambda elm: elm[1])

    zero_ctr = 0
    zero_pos = -1
    for region in regions:
        if region[0] <= zero_pos <= region[1]:
            continue
        zero_pos = region[1]
        zero_ctr += 1
    print(N - zero_ctr)


if __name__ == "__main__":
    main()
0