結果

問題 No.2662 Installing Cell Towers
ユーザー titiatitia
提出日時 2024-03-07 00:18:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 776 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 720 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 52,736 KB
最終ジャッジ日時 2024-03-07 00:18:51
合計ジャッジ時間 7,976 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
9,984 KB
testcase_01 AC 27 ms
9,984 KB
testcase_02 AC 29 ms
9,984 KB
testcase_03 AC 27 ms
9,984 KB
testcase_04 AC 76 ms
13,824 KB
testcase_05 AC 656 ms
52,736 KB
testcase_06 AC 314 ms
25,856 KB
testcase_07 AC 28 ms
9,984 KB
testcase_08 AC 325 ms
25,344 KB
testcase_09 AC 78 ms
13,568 KB
testcase_10 AC 636 ms
50,944 KB
testcase_11 AC 525 ms
46,208 KB
testcase_12 AC 28 ms
9,984 KB
testcase_13 AC 321 ms
27,904 KB
testcase_14 AC 664 ms
51,968 KB
testcase_15 AC 776 ms
50,176 KB
testcase_16 AC 28 ms
9,984 KB
testcase_17 AC 454 ms
48,384 KB
testcase_18 AC 442 ms
48,384 KB
testcase_19 AC 29 ms
9,984 KB
testcase_20 AC 27 ms
9,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,M=map(int,input().split())
ANS=[0]*N
LIST=[[] for i in range(N)]
LIST2=[[] for i in range(N)]

for i in range(M):
    p,q=map(int,input().split())
    p-=1
    LIST[p].append((q,1))

    if p+q<N:
        LIST[p+q].append((0,-1))

    LIST2[p].append((q,1))
    if p-q>=0:
        LIST2[p-q].append((0,-1))
    ANS[p]+=q

NOW,count=0,0

for i in range(N):
    NOW-=count
    ANS[i]+=NOW
    
    for p,c in LIST[i]:
        NOW+=p
        count+=c
        
NOW,count=0,0
for i in range(N-1,-1,-1):

    NOW-=count
    ANS[i]+=NOW

    for p,c in LIST2[i]:
        NOW+=p
        count+=c

print(*ANS)
0