結果

問題 No.274 The Wall
ユーザー rpy3cpprpy3cpp
提出日時 2015-08-28 22:45:12
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 8,568 KB
最終ジャッジ日時 2023-09-04 01:57:28
合計ジャッジ時間 1,826 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,832 KB
testcase_01 AC 16 ms
7,956 KB
testcase_02 AC 15 ms
7,928 KB
testcase_03 AC 18 ms
7,900 KB
testcase_04 AC 15 ms
7,860 KB
testcase_05 AC 15 ms
7,828 KB
testcase_06 AC 16 ms
7,828 KB
testcase_07 AC 15 ms
7,836 KB
testcase_08 AC 15 ms
7,876 KB
testcase_09 AC 16 ms
7,832 KB
testcase_10 AC 16 ms
7,956 KB
testcase_11 AC 21 ms
8,440 KB
testcase_12 AC 21 ms
8,300 KB
testcase_13 AC 16 ms
7,824 KB
testcase_14 AC 18 ms
8,320 KB
testcase_15 AC 19 ms
8,224 KB
testcase_16 AC 20 ms
8,484 KB
testcase_17 AC 20 ms
8,496 KB
testcase_18 AC 20 ms
8,344 KB
testcase_19 AC 21 ms
8,468 KB
testcase_20 AC 21 ms
8,524 KB
testcase_21 AC 21 ms
8,404 KB
testcase_22 AC 21 ms
8,564 KB
testcase_23 AC 21 ms
8,568 KB
testcase_24 AC 21 ms
8,484 KB
testcase_25 AC 21 ms
8,492 KB
権限があれば一括ダウンロードができます

ソースコード

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