結果
問題 | No.1008 Bench Craftsman |
ユーザー | convexineq |
提出日時 | 2020-03-06 23:21:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,624 bytes |
コンパイル時間 | 179 ms |
コンパイル使用メモリ | 82,044 KB |
実行使用メモリ | 132,212 KB |
最終ジャッジ日時 | 2024-04-22 10:36:30 |
合計ジャッジ時間 | 9,197 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
52,400 KB |
testcase_01 | AC | 43 ms
52,996 KB |
testcase_02 | AC | 39 ms
53,108 KB |
testcase_03 | AC | 42 ms
53,600 KB |
testcase_04 | AC | 40 ms
53,736 KB |
testcase_05 | AC | 471 ms
121,984 KB |
testcase_06 | AC | 207 ms
120,264 KB |
testcase_07 | AC | 40 ms
52,800 KB |
testcase_08 | AC | 55 ms
72,584 KB |
testcase_09 | AC | 257 ms
84,888 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 290 ms
131,860 KB |
testcase_16 | WA | - |
testcase_17 | AC | 290 ms
132,212 KB |
testcase_18 | AC | 340 ms
126,200 KB |
testcase_19 | AC | 343 ms
130,420 KB |
testcase_20 | AC | 243 ms
104,804 KB |
testcase_21 | AC | 255 ms
98,272 KB |
testcase_22 | AC | 272 ms
91,280 KB |
testcase_23 | AC | 365 ms
107,160 KB |
testcase_24 | AC | 344 ms
102,284 KB |
testcase_25 | AC | 220 ms
112,204 KB |
testcase_26 | AC | 225 ms
105,964 KB |
testcase_27 | AC | 243 ms
86,640 KB |
testcase_28 | AC | 303 ms
106,908 KB |
testcase_29 | AC | 396 ms
114,508 KB |
ソースコード
# coding: utf-8 # Your code here! import sys readline = sys.stdin.readline read = sys.stdin.read n,m = [int(i) for i in readline().split()] a = [int(i) for i in readline().split()] xw = [[int(i) for i in readline().split()] for _ in range(m)] V = 0 for i in range(m): xw[i][0] -= 1 V += xw[i][1] if V < min(a): print(0) exit() from itertools import accumulate def check(c): #耐久値 x で耐えられるか? imos = [0]*(n) res = [0]*(n) for x,w in xw: res[x] += w v = w//c l = max(0,x-v) r = x-1 #print(l,r) if l < r: X = w-(x-l)*c y = w-c imos[l] += X imos[l+1] += c-X if r+1 < n: imos[r+1] += -y-c if r+2 < n: imos[r+2] += y elif l==r: res[r] += w-c r = min(n-1,x+v) l = x+1 #print(l,r) if l < r: X = w-c y = w-c*(r-x) imos[l] += X imos[l+1] += -c-X if r+1 < n: imos[r+1] += -y+c if r+2 < n: imos[r+1] += y elif l==r: res[r] += w-c #print(x,w,c) #print(imos) #imos = [0]*n imos = accumulate(imos) imos = list(accumulate(imos)) #print(imos,res,a) return all(imos[i]+res[i] < a[i] for i in range(n)) #print(check(2)) ng = 0 ok = M = 10**6 while ok-ng > 1: mid = (ok+ng)//2 if check(mid): ok = mid else: ng = mid if ok < M: print(ok) else: print(-1)