結果

問題 No.2662 Installing Cell Towers
ユーザー 👑 rin204rin204
提出日時 2024-03-16 14:29:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 86,400 KB
最終ジャッジ日時 2024-03-16 14:29:39
合計ジャッジ時間 5,277 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 86 ms
76,384 KB
testcase_05 AC 178 ms
83,328 KB
testcase_06 AC 120 ms
77,344 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 131 ms
77,568 KB
testcase_09 AC 85 ms
76,384 KB
testcase_10 AC 144 ms
82,984 KB
testcase_11 AC 136 ms
82,248 KB
testcase_12 AC 37 ms
53,460 KB
testcase_13 AC 120 ms
77,432 KB
testcase_14 AC 150 ms
83,072 KB
testcase_15 AC 147 ms
83,200 KB
testcase_16 AC 37 ms
53,460 KB
testcase_17 AC 150 ms
86,400 KB
testcase_18 AC 151 ms
86,400 KB
testcase_19 AC 36 ms
53,460 KB
testcase_20 AC 38 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
P = [0] * m
Q = [0] * m
for i in range(m):
    P[i], Q[i] = map(int, input().split())
A = [0] * (n + 10)

for i in range(m):
    P[i] -= 1
    l = P[i] - Q[i]
    r = P[i] + Q[i]
    l = max(l, 0)
    r = min(r, n)
    x = P[i]
    y = Q[i] - abs(x - l)
    A[l] += y
    A[l + 1] -= y - 1
    A[x + 1] -= Q[i] + 1
    A[x + 2] += Q[i]

    A[x + 1] += Q[i] - 1
    A[x + 2] -= Q[i]
    y = Q[i] - abs(x - r)
    A[r + 1] += 1


for i in range(1, n + 10):
    A[i] += A[i - 1]
for i in range(1, n + 10):
    A[i] += A[i - 1]

print(*A[:n])
0