結果
問題 | No.1008 Bench Craftsman |
ユーザー | convexineq |
提出日時 | 2020-03-07 01:05:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 350 ms / 2,000 ms |
コード長 | 1,183 bytes |
コンパイル時間 | 218 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 123,720 KB |
最終ジャッジ日時 | 2024-04-22 11:39:34 |
合計ジャッジ時間 | 7,638 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
52,352 KB |
testcase_01 | AC | 38 ms
52,480 KB |
testcase_02 | AC | 38 ms
52,096 KB |
testcase_03 | AC | 38 ms
52,608 KB |
testcase_04 | AC | 37 ms
52,736 KB |
testcase_05 | AC | 350 ms
114,236 KB |
testcase_06 | AC | 173 ms
114,180 KB |
testcase_07 | AC | 37 ms
52,608 KB |
testcase_08 | AC | 53 ms
72,192 KB |
testcase_09 | AC | 232 ms
84,992 KB |
testcase_10 | AC | 286 ms
115,972 KB |
testcase_11 | AC | 300 ms
116,028 KB |
testcase_12 | AC | 300 ms
119,364 KB |
testcase_13 | AC | 303 ms
122,676 KB |
testcase_14 | AC | 297 ms
119,352 KB |
testcase_15 | AC | 267 ms
123,720 KB |
testcase_16 | AC | 279 ms
117,564 KB |
testcase_17 | AC | 261 ms
123,156 KB |
testcase_18 | AC | 315 ms
119,304 KB |
testcase_19 | AC | 304 ms
121,804 KB |
testcase_20 | AC | 193 ms
99,812 KB |
testcase_21 | AC | 193 ms
97,068 KB |
testcase_22 | AC | 221 ms
91,636 KB |
testcase_23 | AC | 258 ms
106,224 KB |
testcase_24 | AC | 257 ms
101,300 KB |
testcase_25 | AC | 182 ms
103,952 KB |
testcase_26 | AC | 165 ms
101,500 KB |
testcase_27 | AC | 200 ms
85,884 KB |
testcase_28 | AC | 224 ms
100,588 KB |
testcase_29 | AC | 287 ms
111,516 KB |
ソースコード
# coding: utf-8 # Your code here! """ a(x-p) + b (p <= x <= q) の2階階差をとり、imos配列に加える """ def kaisa2_of_tousa(a,b,p,q,imos): if p > q: return imos[p] += b if p+1 < n: imos[p+1] += a-b y = a*(q-p)+b if q+1 < n: imos[q+1] += -y-a if q+2 < n: imos[q+2] += y return 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) for x,w in xw: v = w//c l = max(0,x-v) kaisa2_of_tousa(c,w-c*(x-l),l,x-1,imos) kaisa2_of_tousa(-c,w,x,min(n-1,x+v),imos) imos = accumulate(imos) imos = list(accumulate(imos)) return all(im < ai for im,ai in zip(imos,a)) ng = 0 ok = M = 10**5+9 while ok-ng > 1: mid = (ok+ng)//2 if check(mid): ok = mid else: ng = mid if ok < M: print(ok) else: print(-1)