結果

問題 No.2662 Installing Cell Towers
ユーザー ntudantuda
提出日時 2024-03-10 21:07:56
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 448 bytes
コンパイル時間 2,694 ms
コンパイル使用メモリ 81,444 KB
実行使用メモリ 92,684 KB
最終ジャッジ日時 2024-03-10 21:08:04
合計ジャッジ時間 5,854 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 35 ms
53,460 KB
testcase_04 AC 83 ms
76,796 KB
testcase_05 AC 190 ms
92,684 KB
testcase_06 AC 146 ms
84,444 KB
testcase_07 AC 36 ms
53,460 KB
testcase_08 AC 155 ms
86,284 KB
testcase_09 AC 82 ms
76,796 KB
testcase_10 AC 177 ms
92,256 KB
testcase_11 AC 161 ms
89,968 KB
testcase_12 RE -
testcase_13 AC 158 ms
86,024 KB
testcase_14 AC 177 ms
92,684 KB
testcase_15 AC 171 ms
92,684 KB
testcase_16 AC 36 ms
53,460 KB
testcase_17 AC 174 ms
92,684 KB
testcase_18 AC 173 ms
92,684 KB
testcase_19 AC 36 ms
53,460 KB
testcase_20 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
PQ = [list(map(int,input().split())) for _ in range(M)]
A = [0] * N
B = [0] * N
C = [0] * N

for p,q in PQ:
    p -= 1
    if p - q + 1 < 0:
        A[0] += q - p
        A[1] -= q - p - 1
    else:
        A[p - q + 1] += 1
    if p + 1 < N:
        A[p + 1] -= 2
    if p + q + 1 < N:
        A[p + q + 1] += 1
B[0] = A[0]
C[0] = A[0]
for i in range(1,N):
    B[i] = B[i-1] + A[i]
    C[i] = C[i-1] + B[i]
print(*C)
0