結果

問題 No.274 The Wall
ユーザー lloyzlloyz
提出日時 2023-09-24 15:35:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 435 bytes
コンパイル時間 1,078 ms
コンパイル使用メモリ 86,824 KB
実行使用メモリ 78,388 KB
最終ジャッジ日時 2023-09-24 15:35:14
合計ジャッジ時間 5,166 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,176 KB
testcase_01 AC 78 ms
75,816 KB
testcase_02 AC 79 ms
76,040 KB
testcase_03 AC 100 ms
76,772 KB
testcase_04 AC 74 ms
71,336 KB
testcase_05 AC 73 ms
71,212 KB
testcase_06 AC 73 ms
71,344 KB
testcase_07 AC 75 ms
71,308 KB
testcase_08 AC 72 ms
71,424 KB
testcase_09 AC 75 ms
71,460 KB
testcase_10 AC 84 ms
75,964 KB
testcase_11 AC 103 ms
76,892 KB
testcase_12 AC 120 ms
78,124 KB
testcase_13 AC 86 ms
76,024 KB
testcase_14 AC 104 ms
76,304 KB
testcase_15 AC 126 ms
77,836 KB
testcase_16 AC 106 ms
76,888 KB
testcase_17 AC 105 ms
76,884 KB
testcase_18 AC 103 ms
76,752 KB
testcase_19 AC 131 ms
78,076 KB
testcase_20 AC 132 ms
77,880 KB
testcase_21 AC 132 ms
78,388 KB
testcase_22 AC 106 ms
77,280 KB
testcase_23 AC 127 ms
77,940 KB
testcase_24 AC 135 ms
77,872 KB
testcase_25 AC 129 ms
77,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
LR = []
for _ in range(n):
    l, r = map(int, input().split())
    r += 1
    l, r = min((l, r), (m - r, m - l))
    LR.append((l, r))
used = [False for _ in range(m)]
for l, r in sorted(LR):
    if any(used[i] for i in range(l, r)):
        l, r = m - r, m - l
    if any(used[i] for i in range(l, r)):
        print("NO")
        exit()
    for i in range(l, r):
        used[i] = True
print("YES")
0