結果
問題 | No.1037 exhausted |
ユーザー | convexineq |
提出日時 | 2020-04-24 22:24:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,991 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 77,696 KB |
最終ジャッジ日時 | 2024-10-15 03:07:18 |
合計ジャッジ時間 | 2,875 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
53,760 KB |
testcase_01 | AC | 46 ms
53,888 KB |
testcase_02 | AC | 46 ms
53,888 KB |
testcase_03 | AC | 46 ms
54,144 KB |
testcase_04 | WA | - |
testcase_05 | AC | 46 ms
54,144 KB |
testcase_06 | AC | 46 ms
54,144 KB |
testcase_07 | AC | 46 ms
54,016 KB |
testcase_08 | AC | 46 ms
53,760 KB |
testcase_09 | AC | 47 ms
53,888 KB |
testcase_10 | AC | 46 ms
53,760 KB |
testcase_11 | WA | - |
testcase_12 | AC | 109 ms
77,312 KB |
testcase_13 | AC | 113 ms
77,184 KB |
testcase_14 | WA | - |
testcase_15 | AC | 111 ms
76,800 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 106 ms
76,672 KB |
testcase_19 | AC | 111 ms
77,056 KB |
testcase_20 | AC | 99 ms
77,056 KB |
testcase_21 | AC | 101 ms
76,672 KB |
testcase_22 | AC | 102 ms
77,056 KB |
ソースコード
""" sliding window aggrigation モノイドのqueueを管理する fold_all: すべてをたたみこむ popleft append """ from itertools import accumulate from collections import deque class SWAG: def __init__(self, operator_M, e_M): self.op_M = operator_M self.op_rev = lambda x,y: self.op_M(y,x) self.e_M = e_M self.q = deque([]) self.accL = [] self.accR = e_M self.L = self.R = 0 def build(self,lst): self.q = deque(lst) self.L = len(lst) self.accL = list(accumulate(reversed(lst),self.op_rev)) def __len__(self): return self.L + self.R def fold_all(self): if self.L: return self.op_M(self.accL[-1],self.accR) else: return self.accR def append(self,x): self.q.append(x) self.accR = self.op_M(self.accR,x) self.R += 1 def popleft(self): if self.L: self.accL.pop() self.L -= 1 return self.q.popleft() elif self.R: v = self.q.popleft() self.L,self.R = self.R-1,0 self.accL = list(accumulate(reversed(self.q),self.op_rev)) self.accR = self.e_M return v else: assert 0 def __repr__(self): return "{}\naccL:{}, accR:{}".format(self.q,self.accL,self.accR) # coding: utf-8 # Your code here! import sys readline = sys.stdin.readline read = sys.stdin.read n,V,L = [int(i) for i in readline().split()] xvw = [[int(i) for i in readline().split()] for _ in range(n)] n += 1 xvw.append([L,0,0]) INF = 10**18 dp = [INF]*(V+1) dp[V] = 0 D = [xvw[0][0]] + [xvw[i+1][0]-xvw[i][0] for i in range(n-1)] + [L - xvw[-2][0]] for (x,v,w),d in zip(xvw,D): ndp = [INF]*(V+1) for i in range(V+1-d): ndp[i] = dp[i+d] for i in range(V,v-1,-1): ndp[i] = min(ndp[i],ndp[i-v]+w) dp = ndp #print(dp) x = min(dp) if x == INF: print(-1) else: print(x)