結果

問題 No.274 The Wall
ユーザー maspymaspy
提出日時 2020-03-12 21:58:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 783 bytes
コンパイル時間 69 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 30,148 KB
最終ジャッジ日時 2023-09-04 02:48:39
合計ジャッジ時間 6,423 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
29,444 KB
testcase_01 AC 131 ms
29,452 KB
testcase_02 AC 130 ms
29,656 KB
testcase_03 AC 130 ms
29,612 KB
testcase_04 AC 129 ms
29,648 KB
testcase_05 AC 131 ms
29,572 KB
testcase_06 AC 130 ms
29,648 KB
testcase_07 AC 130 ms
29,660 KB
testcase_08 AC 130 ms
29,568 KB
testcase_09 AC 130 ms
29,556 KB
testcase_10 AC 128 ms
29,620 KB
testcase_11 AC 132 ms
30,052 KB
testcase_12 AC 137 ms
30,088 KB
testcase_13 AC 130 ms
29,588 KB
testcase_14 AC 134 ms
29,776 KB
testcase_15 AC 137 ms
29,752 KB
testcase_16 AC 134 ms
29,948 KB
testcase_17 AC 135 ms
29,944 KB
testcase_18 AC 134 ms
29,880 KB
testcase_19 AC 144 ms
29,912 KB
testcase_20 AC 140 ms
29,944 KB
testcase_21 AC 140 ms
30,120 KB
testcase_22 AC 133 ms
29,924 KB
testcase_23 AC 139 ms
30,084 KB
testcase_24 AC 141 ms
30,148 KB
testcase_25 AC 141 ms
30,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3.8
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from operator import itemgetter

# %%
N, M = map(int, readline().split())
m = map(int, read().split())
LR = zip(m, m)


# %%
def solve(N, M, LR):
    blocks = []
    for L, R in LR:
        L1, R1 = M - 1 - R, M - 1 - L
        if L < L1:
            blocks.append((L, R))
        else:
            blocks.append((L1, R1))
    blocks.sort(key=itemgetter(0))
    A = np.zeros(M, np.int64)
    for L, R in blocks:
        if A[L: R + 1].any():
            A = A[::-1]
            if A[L: R + 1].any():
                return False
        A[L: R + 1] = 1
    return True


# %%
print('YES' if solve(N, M, LR) else 'NO')
0