結果

問題 No.2662 Installing Cell Towers
ユーザー 2bit2bit
提出日時 2023-03-04 17:31:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 676 ms / 2,000 ms
コード長 411 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 19,456 KB
最終ジャッジ日時 2024-03-16 02:03:40
合計ジャッジ時間 7,137 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,112 KB
testcase_01 AC 29 ms
10,112 KB
testcase_02 AC 30 ms
10,112 KB
testcase_03 AC 29 ms
10,112 KB
testcase_04 AC 93 ms
10,752 KB
testcase_05 AC 607 ms
19,200 KB
testcase_06 AC 362 ms
11,264 KB
testcase_07 AC 28 ms
10,112 KB
testcase_08 AC 414 ms
10,112 KB
testcase_09 AC 87 ms
10,752 KB
testcase_10 AC 570 ms
19,328 KB
testcase_11 AC 487 ms
18,304 KB
testcase_12 AC 31 ms
10,112 KB
testcase_13 AC 421 ms
10,112 KB
testcase_14 AC 593 ms
19,328 KB
testcase_15 AC 676 ms
16,128 KB
testcase_16 AC 29 ms
10,112 KB
testcase_17 AC 556 ms
19,456 KB
testcase_18 AC 550 ms
19,456 KB
testcase_19 AC 29 ms
10,112 KB
testcase_20 AC 29 ms
10,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
ans = [0]*(N+2)
S = [0]*(N+2)
def add(l,r,C,c=1):
  ans[l] += C
  ans[r] -= C
  S[l] += c
  S[r] -= c
for _ in range(M):
  p,q = map(int,input().split())
  a = q - p
  if 0 <= a:
    add(1,p,a)
  else:
    add(min(abs(a)+1,p),p,a)
  b = p + q
  add(p,min(b+1,N+1),b,-1)
for i in range(1,N+1):
  S[i + 1] += S[i]
  ans[i + 1] += ans[i]
  print(ans[i] + S[i] * i,end = " ")
print()
0