結果
問題 |
No.2662 Installing Cell Towers
|
ユーザー |
|
提出日時 | 2025-03-21 20:37:56 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 470 ms / 2,000 ms |
コード長 | 997 bytes |
コンパイル時間 | 266 ms |
コンパイル使用メモリ | 81,724 KB |
実行使用メモリ | 109,936 KB |
最終ジャッジ日時 | 2025-03-21 20:38:05 |
合計ジャッジ時間 | 7,462 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) input = sys.stdin.readline n,m = map(int,input().split()) check = [[] for i in range(n)] c = [0 for i in range(n)] for i in range(m): p,q = map(int,input().split()) p -= 1 check[p].append(q) r = [0 for i in range(n)] temp = 0 cnt = 0 h = [] for i in range(n): for j in check[i]: temp += j cnt += 1 heapq.heappush(h,i+j) r[i] = temp while h and h[0] == i: cnt -= 1 heapq.heappop(h) temp = max(temp-cnt,0) l = [0 for i in range(n)] temp = 0 cnt = 0 h = [] for i in reversed(range(n)): for j in check[i]: temp += j cnt += 1 heapq.heappush(h,-(i-j)) l[i] = temp while h and h[0] == -i: cnt -= 1 heapq.heappop(h) temp = max(temp-cnt,0) for i in range(n): print(l[i]+r[i]-sum(check[i]),end=' ') #0 1 3 4 5 5 3 2 1 0