結果

問題 No.274 The Wall
ユーザー rpy3cpp
提出日時 2015-08-28 22:45:12
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2025-03-17 18:46:18
合計ジャッジ時間 1,860 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    N, M = map(int, input().split())
    LR = []
    for n in range(N):
        L, R = map(int, input().split())
        LR.append((L, R))
    return N, M, LR

def solve(N, M, LR):
    imos = [0] * (M + 1)
    for L, R in LR:
        imos[L] += 1
        imos[R + 1] -= 1
        imos[M - R - 1] += 1
        imos[M - L] -= 1
    cum = 0
    for v in imos:
        cum += v
        if cum > 2:
            return False
    return True

N, M, LR = read_data()
if solve(N, M, LR):
    print('YES')
else:
    print('NO')
0