結果

問題 No.274 The Wall
ユーザー chocoruskchocorusk
提出日時 2020-09-19 23:05:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 11,004 KB
実行使用メモリ 8,732 KB
最終ジャッジ日時 2023-09-06 01:56:40
合計ジャッジ時間 1,592 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,880 KB
testcase_01 AC 15 ms
8,336 KB
testcase_02 AC 15 ms
7,908 KB
testcase_03 AC 17 ms
8,388 KB
testcase_04 AC 16 ms
8,160 KB
testcase_05 AC 16 ms
7,824 KB
testcase_06 AC 16 ms
8,220 KB
testcase_07 AC 16 ms
7,832 KB
testcase_08 AC 15 ms
7,908 KB
testcase_09 AC 16 ms
8,284 KB
testcase_10 AC 16 ms
7,828 KB
testcase_11 AC 17 ms
8,636 KB
testcase_12 AC 18 ms
8,656 KB
testcase_13 AC 16 ms
7,912 KB
testcase_14 AC 17 ms
8,292 KB
testcase_15 AC 18 ms
8,432 KB
testcase_16 AC 18 ms
8,716 KB
testcase_17 AC 19 ms
8,620 KB
testcase_18 AC 18 ms
8,620 KB
testcase_19 AC 19 ms
8,732 KB
testcase_20 AC 19 ms
8,584 KB
testcase_21 AC 19 ms
8,712 KB
testcase_22 AC 19 ms
8,688 KB
testcase_23 AC 20 ms
8,572 KB
testcase_24 AC 19 ms
8,604 KB
testcase_25 AC 19 ms
8,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines

n, m=map(int, readline().split())
lr=list(map(int, read().split()))
ls=lr[::2]
rs=lr[1::2]
for i in range(n):
    if m-1-rs[i]<ls[i]:
        ls[i], rs[i]=m-1-rs[i], m-1-ls[i]
lrs=sorted(list(zip(ls, rs)))
x1, x2=-1, -1
for l, r in lrs:
    if x1<l and x2<l:
        if x1<x2:
            x2=r
        else:
            x1=r
    elif x1<l:
        x1=r
    elif x2<l:
        x2=r
    else:
        print("NO")
        exit()
if x1+x2+2<=m:
    print("YES")
else:
    print("NO")
0