結果

問題 No.728 ギブ and テイク
ユーザー rookzenorookzeno
提出日時 2018-08-25 12:20:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 543 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 19,684 KB
最終ジャッジ日時 2023-09-07 13:20:18
合計ジャッジ時間 6,277 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,128 KB
testcase_01 AC 16 ms
8,136 KB
testcase_02 AC 16 ms
8,112 KB
testcase_03 AC 16 ms
8,160 KB
testcase_04 AC 17 ms
8,052 KB
testcase_05 AC 17 ms
8,180 KB
testcase_06 AC 17 ms
8,152 KB
testcase_07 AC 17 ms
8,108 KB
testcase_08 AC 18 ms
8,176 KB
testcase_09 AC 17 ms
8,128 KB
testcase_10 AC 18 ms
8,176 KB
testcase_11 AC 23 ms
8,040 KB
testcase_12 AC 31 ms
8,284 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import bisect
n=int(input())
a = list(map(int,input().split()))
x = [list(map(int,input().split())) for _ in  range(n)]
ki = [[-1,-1]for i in range(n)]
for i in range(n):
  mi = a[i]-x[i][0]
  hi = a[i]+x[i][1]
  migi= bisect.bisect_left(a,mi)
  hida = bisect.bisect_right(a,hi)
  if a[migi-1] < mi:
    migi += 1
  ki[i][0] = migi
  ki[i][1] = hida
dp = [0] * n
ans = 0
for i in range(n):
  mi = ki[i][0]
  hi = ki[i][1]
  if mi == 0:
    mi+=1
  for j in range(mi-1,i):
    if dp[j] >= i:
      ans += 1
  dp[i] = hi-1
print(ans)
0