結果

問題 No.274 The Wall
ユーザー compass19compass19
提出日時 2017-01-04 21:47:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 10,760 KB
実行使用メモリ 8,728 KB
最終ジャッジ日時 2023-09-04 02:14:42
合計ジャッジ時間 1,774 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,120 KB
testcase_01 AC 18 ms
8,256 KB
testcase_02 AC 18 ms
8,172 KB
testcase_03 AC 20 ms
8,256 KB
testcase_04 AC 16 ms
8,120 KB
testcase_05 AC 16 ms
7,836 KB
testcase_06 AC 16 ms
8,272 KB
testcase_07 AC 16 ms
7,848 KB
testcase_08 AC 17 ms
7,792 KB
testcase_09 AC 17 ms
8,288 KB
testcase_10 AC 16 ms
8,188 KB
testcase_11 AC 22 ms
8,728 KB
testcase_12 AC 24 ms
8,644 KB
testcase_13 AC 17 ms
7,832 KB
testcase_14 AC 19 ms
8,396 KB
testcase_15 AC 22 ms
8,420 KB
testcase_16 AC 23 ms
8,676 KB
testcase_17 AC 23 ms
8,560 KB
testcase_18 AC 22 ms
8,588 KB
testcase_19 AC 24 ms
8,640 KB
testcase_20 AC 25 ms
8,460 KB
testcase_21 AC 26 ms
8,600 KB
testcase_22 AC 24 ms
8,704 KB
testcase_23 AC 25 ms
8,636 KB
testcase_24 AC 25 ms
8,616 KB
testcase_25 AC 25 ms
8,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
blocks = [tuple(map(int, input().split())) for _ in range(n)]
blocks[:] = [(l, r) if l <  m // 2 else (m - r - 1, m - l - 1) for l, r in blocks]
blocks = sorted(blocks, key=lambda x: (x[0], x[1]))

pink_block = [True]*m
def update(l, r):
    if all(pink_block[l:r+1]):
        pink_block[l:r+1] = [False]*(r-l+1)
        return True
    return False

for l, r in blocks:
    if not update(l, r):
        l, r = m - r - 1, m - l - 1
        if not update(l, r):
            print('NO'); exit()
print('YES')
0