s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s161593728
p03731
u732491892
1494714837
Python
Python (3.4.3)
py
Runtime Error
36
19220
245
n, t = map(int, input().split(' ')) tlist = map(int, input().split(' ')) sum_time = 0 for i in range(1, len(tlist)): delta = tlist[i] - tlist[i-1] shower = delta if delta <= t else t sum_time += shower sum_time += t print(sum_time)
s439750742
p03731
u619384481
1494210087
Python
Python (2.7.6)
py
Runtime Error
10
2568
230
ini=map(int,raw_input().split()) a=map(int,raw_input().split()) sum=0 for i in range(ini[0]): if a{i]==0: pass else: if a[i]-a[i-1]>=ini[1]: sum+=ini[1] else: sum+= a[i]-a[i-1] sum+=ini[1] print sum
s673094899
p03731
u682181971
1493529350
Python
Python (3.4.3)
py
Runtime Error
43
20856
202
N, T =map(int, input().split()) ts =map(int, input().split()) amount =0 for index in range(N-1): t_sub = ts[index+1]-ts[index] amount+=min(t_sub,T) amount +=T print(amount)
s544772164
p03731
u682181971
1493527224
Python
Python (3.4.3)
py
Runtime Error
37
20852
193
N,T =map(int,input().split()) t = map(int,input().split()) amount =0 for index in range(N-1): t_sub = t[index+1]-t[index] amount+=min(t_sub,T) amount +=T print(amount)
s692786940
p03731
u682181971
1493526842
Python
Python (3.4.3)
py
Runtime Error
36
19216
237
N,T =map(int,input().split()) t = map(int,input().split()) amount =0 for index in range(N-1): t_sub = t[index+1]-t[index] if t_sub <= T: amount+=t_sub else: amount+=T amount +=T print(amount)
s856285052
p03731
u682181971
1493526613
Python
Python (3.4.3)
py
Runtime Error
37
20856
229
N,T =map(int,input().split()) t = input().split() amount =0 for index in range(N-1): t_sub = t[index+1]-t[index] if t_sub <= T: amount+=t_sub else: amount+=T amount +=T print(amount)
s454487624
p03731
u682181971
1493526150
Python
Python (3.4.3)
py
Runtime Error
36
20856
289
N,T = map(int,input().split()) t = input().split() amount =0 if t[0] <= T: amount+=t[0] else: amount+=T for index in range(N-1): t_sub = int(t[index+1])-int(t[index]) if t_sub <= T: amount+=t_sub else: amount+=T amount +=T print(amount)
s907028564
p03731
u682181971
1493525889
Python
Python (3.4.3)
py
Runtime Error
17
3064
292
N,T = map(int,input().split) t = input().split() int(amount) =0 if t[0] <= T: amount+=t[0] else: amount+=T for index in range(N-1): t_sub = int(t[index+1])-int(t[index]) if t_sub <= T: amount+=t_sub else: amount+=T amount +=T print(amount)
s368311400
p03731
u682181971
1493525797
Python
Python (3.4.3)
py
Runtime Error
18
3064
277
N,T = map(int,input().split) t = input().split() amount =0 if t[0] <= T: amount+=t[0] else: amount+=T for index in range(N-1): t_sub = t[index+1]-t[index] if t_sub <= T: amount+=t_sub else: amount+=T amount +=T print(amount)
s821341871
p03731
u484578205
1493521227
Python
Python (3.4.3)
py
Runtime Error
139
26836
131
N, T = map(int, input().split()) ts = list(map(int, input().split())) s = 0; for i in range(N): s += min(ts[i + 1], T) print(s)
s811351692
p03731
u402666025
1493519252
Python
Python (3.4.3)
py
Runtime Error
52
20852
208
N, T = map(int, input().split()) t = list(map(str, input().split())) _all = N * T sabun = 0 for i in range(0, N): if T < t[i]: sabun += 0 else: sabun += T - t[i] print(_all - sabun)
s113317204
p03731
u402666025
1493519207
Python
Python (3.4.3)
py
Runtime Error
17
2940
208
N, T = map(int, input().split()) t = list(map(str, input().split())) _all = N * T sabun = 0 for i in range(0, N): if T < t[i]: sabun += 0 elif: sabun += T - t[i] print(_all - sabun)
s114488334
p03731
u256260242
1493517705
Python
Python (3.4.3)
py
Runtime Error
66
25200
344
##N T #t1 t2 ... tN N, T = map(int,input().split()) a = list(map(int, input().split())) b = [] """ for i in range(N): set1 = set() for j in range(T): set1.add(a[i] + j) b.append(set1) d = set() for n in range(len(b)): d = d | b[n] """ d = set() for i in xrange(N): d = d | set(xrange(a[i], a[...
s173675039
p03731
u803848678
1493515906
Python
Python (3.4.3)
py
Runtime Error
29
8604
145
N, T = list(map(int, input().split())) t = [int(input()) for i in range(N)] ans = N*T for i in t: if i < T: ans -= T - i print(ans)
s728145097
p03731
u341926204
1493515115
Python
Python (3.4.3)
py
Runtime Error
40
19216
136
n, t = map(int, input().split()) ti = map(int, input().split()) ttl = t for i in range(n-1): ttl += min(ti[i+1]-ti[i], t) print(ttl)
s740533755
p03732
u347640436
1599736191
Python
Python (3.8.2)
py
Runtime Error
27
9236
929
from sys import stdin from itertools import accumulate readline = stdin.readline N, W = map(int, input().split()) vs = [[] for _ in range(4)] w, v = map(int, input().split()) w1 = w vs[0].append(v) for _ in range(N - 1): w, v = map(int, input().split()) vs[w - w1].append(v) for i in range(4): vs[i].sort(r...
s889838715
p03732
u070201429
1598542904
Python
PyPy3 (7.3.0)
py
Runtime Error
101
75160
716
from sys import stdin def input(): return stdin.readline().strip() n, weight = map(int, input().split()) w, v = [0]*n, [0]*n for i in range(n): w[i], v[i] = map(int, input().split()) base = w[0] #q, r = divmod(weight, base) for i in range(n): w[i] -= base # dp[i][j] = i個選んで重さの余りがjの時の、価値の最大値 dp = [[0] * ...
s400246373
p03732
u453055089
1598423005
Python
Python (3.8.2)
py
Runtime Error
2024
3505528
680
n, W = map(int, input().split()) w_v = [list(map(int, input().split())) for _ in range(n)] #dp = [[0]*(W+1) for _ in range(n+1)] #dp[i][w]はi番目までの品物の中から重さw以下なるように選んだときの価値の総和の最大値 dp = [[0]*(W+1) for _ in range(2)] #dp[0][w]は最新の偶数インデックスの値 #dp[1][w]は最新の奇数インデックスの値 ans = 0 for i in range(n): mod = i % 2 for w in rang...
s110660233
p03732
u453055089
1598422957
Python
PyPy3 (7.3.0)
py
Runtime Error
2337
3515476
680
n, W = map(int, input().split()) w_v = [list(map(int, input().split())) for _ in range(n)] #dp = [[0]*(W+1) for _ in range(n+1)] #dp[i][w]はi番目までの品物の中から重さw以下なるように選んだときの価値の総和の最大値 dp = [[0]*(W+1) for _ in range(2)] #dp[0][w]は最新の偶数インデックスの値 #dp[1][w]は最新の奇数インデックスの値 ans = 0 for i in range(n): mod = i % 2 for w in rang...
s005092674
p03732
u453055089
1598420708
Python
PyPy3 (7.3.0)
py
Runtime Error
2098
3489368
462
n, W = map(int, input().split()) w_v = [list(map(int, input().split())) for _ in range(n)] dp = [[0]*(W+1) for _ in range(n+1)] #dp[i][w]はi番目までの品物の中から重さw以下なるように選んだときの価値の総和の最大値 for i in range(n): for w in range(W+1): if w - w_v[i][0] >= 0: dp[i+1][w] = max(dp[i][w], dp[i][w - w_v[i][0]] + w_v[i]...
s382131444
p03732
u162612857
1597290662
Python
Python (3.8.2)
py
Runtime Error
2192
106320
2082
# 普通のナップサックは O(荷物の数、ナップサックに入る重量の上限)で計算できる。 # 今回はこれだと O(100 * 10**9) なので無理。 # 明らかに条件で重要なのは「すべてのi=2,3,...,Nについて、w_1<=w_i<=w_1+3」 # w_1が1000とする # W = 4500→4つが必ず入り、5つは必ず入らない。価値の高いものから4つ。 # W = 4005→3つが必ず入る。4つが入るかどうかは場合による。 # max(3つの場合, 4つの場合)。3つは価値の高いものから3つ。4つは? # 4つ選ぶ、4005以下、価値最大化 # dp[i][k][l] # w_1〜w_iの中からk個選んで、重量をちょう...
s228740139
p03732
u162612857
1597290626
Python
PyPy3 (7.3.0)
py
Runtime Error
356
99580
2082
# 普通のナップサックは O(荷物の数、ナップサックに入る重量の上限)で計算できる。 # 今回はこれだと O(100 * 10**9) なので無理。 # 明らかに条件で重要なのは「すべてのi=2,3,...,Nについて、w_1<=w_i<=w_1+3」 # w_1が1000とする # W = 4500→4つが必ず入り、5つは必ず入らない。価値の高いものから4つ。 # W = 4005→3つが必ず入る。4つが入るかどうかは場合による。 # max(3つの場合, 4つの場合)。3つは価値の高いものから3つ。4つは? # 4つ選ぶ、4005以下、価値最大化 # dp[i][k][l] # w_1〜w_iの中からk個選んで、重量をちょう...
s086513200
p03732
u955248595
1596395699
Python
Python (3.8.2)
py
Runtime Error
1967
3513580
640
def KnapsackDP(N,WMax,WVList): DP = [[0]*(WMax+1) for T in range(N+1)] for I in range(0,N): for K in range(0,WMax+1): if K<WVList[I][0]: DP[I+1][K] = DP[I][K] else: if DP[I][K]>DP[I][K-WVList[I][0]]+WVList[I][1]: DP[I+1][K]...
s380048939
p03732
u969708690
1596227439
Python
PyPy3 (7.3.0)
py
Runtime Error
2081
3504756
357
N,W = map(int,input().split()) w = [] v = [] for i in range(N): x,y = map(int,input().split()) w.append(x) v.append(y) dp = [[0]*(W+1) for j in range(N+1)] for i in range(N): for j in range(W+1): if j < w[i]: dp[i+1][j] = dp[i][j] else: dp[i+1][j] = max(dp[i][j]...
s916372563
p03732
u980783809
1596119389
Python
PyPy3 (7.3.0)
py
Runtime Error
2218
366760
1087
n, w = map(int, input().split()) items = [list(map(int, input().split())) for _ in range(n)] if w < items[0][0] : print(0) exit() w_sum = 0 v_sum = 0 for i in range(n): w_sum += items[i][0] v_sum += items[i][1] if w >= w_sum: print(v_sum) exit() dp = {} #for j in range(items[0][0],w+1): cnt_l = ...
s507671190
p03732
u980783809
1596074610
Python
PyPy3 (7.3.0)
py
Runtime Error
2136
3510280
938
n, w = map(int, input().split()) items = [list(map(int, input().split())) for _ in range(n)] if w < items[0][0] : print(0) exit() w_sum = 0 v_sum = 0 for i in range(n): w_sum += items[i][0] v_sum += items[i][1] if w >= w_sum: print(v_sum) exit() dp2 = [[0]*(w+1) for _ in range(n+1)] dp = {} for ...
s201651067
p03732
u968166680
1595675865
Python
PyPy3 (7.3.0)
py
Runtime Error
88
74724
1560
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def solve1(N, W, weight, value): dp = [[0] * (W + 1) for _ in range(N + 1)] for i in range(N): for w in range(W + 1): if w - weight[...
s426257901
p03732
u814781830
1594573468
Python
PyPy3 (7.3.0)
py
Runtime Error
93
81324
417
N, W = map(int, input().split()) w = [0] * N v = [0] * N for i in range(N): w[i], v[i] = map(int, input().split()) dp = [[0] * 10010 for _ in range(N+1)] minw = min(w) for i in range(N): w[i] -= minw w[i] += 1 for i in range(N): for j in range(10000): dp[i+1][j] = dp[i][j] if j-w[i] >= ...
s227869957
p03732
u814781830
1594573065
Python
PyPy3 (7.3.0)
py
Runtime Error
115
82208
430
N, W = map(int, input().split()) w = [0] * N v = [0] * N for i in range(N): x, y = map(int, input().split()) w[i] = x v[i] = y dp = [[0] * 10010 for _ in range(N+1)] minw = min(w) for i in range(N): w[i] -= minw w[i] += 1 for i in range(N): for j in range(10000): dp[i+1][j] = dp[i][j] ...
s120162195
p03732
u814781830
1594573042
Python
PyPy3 (7.3.0)
py
Runtime Error
91
75588
429
N, W = map(int, input().split()) w = [0] * N v = [0] * N for i in range(N): x, y = map(int, input().split()) w[i] = x v[i] = y dp = [[0] * 1010 for _ in range(N+1)] minw = min(w) for i in range(N): w[i] -= minw w[i] += 1 for i in range(N): for j in range(10000): dp[i+1][j] = dp[i][j] ...
s438640868
p03732
u814781830
1594572966
Python
PyPy3 (7.3.0)
py
Runtime Error
103
69796
428
N, W = map(int, input().split()) w = [0] * N v = [0] * N for i in range(N): x, y = map(int, input().split()) w[i] = x v[i] = y dp = [[0] * 1010 for _ in range(N+1)] minw = min(w) for i in range(N): w[i] -= minw w[i] += 1 for i in range(N): for j in range(1000): dp[i+1][j] = dp[i][j] ...
s232274346
p03732
u926046014
1594179924
Python
PyPy3 (7.3.0)
py
Runtime Error
88
74816
709
N,W=map(int,input().split()) a,v=map(int,input().split()) w0=[v] w1=[] w2=[] w3=[] for i in range(N-1): w,v=map(int,input().split()) if w-a==0: w0.append(v) elif w-a==1: w1.append(v) elif w-a==2: w2.append(v) else: w3.appned(v) w0=sorted(w0,reverse=True) w1=sorted(w1,...
s483398561
p03732
u926046014
1594176203
Python
PyPy3 (7.3.0)
py
Runtime Error
1965
2793820
265
N,W=map(int,input().split()) lst=[-1]*(W+1) lst[0]=0 for i in range(N): w,v=map(int,input().split()) for j in range(W-w,-1,-1): if lst[j]!=-1: Value=lst[j]+v if Value>lst[j+w]: lst[j+w]=Value print(max(lst))
s442662562
p03732
u926046014
1594174018
Python
PyPy3 (7.3.0)
py
Runtime Error
1889
2794064
265
N,W=map(int,input().split()) lst=[-1]*(W+1) lst[0]=0 for i in range(N): w,v=map(int,input().split()) for i in range(W-w,-1,-1): if lst[i]!=-1: Value=lst[i]+v if Value>lst[i+w]: lst[i+w]=Value print(max(lst))
s474018976
p03732
u145231176
1593351523
Python
PyPy3 (7.3.0)
py
Runtime Error
2193
3521452
1992
def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(input()) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): return random.randint(ran1,...
s513681045
p03732
u145231176
1593349707
Python
PyPy3 (7.3.0)
py
Runtime Error
2185
3520836
1976
def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(input()) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): return random.randint(ran1,...
s109156049
p03732
u145231176
1593349413
Python
PyPy3 (7.3.0)
py
Runtime Error
2188
3537320
1938
def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(input()) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): return random.randint(ran1,...
s418147646
p03732
u583507988
1593286721
Python
Python (3.8.2)
py
Runtime Error
1903
3539012
365
n, W = map(int, input().split()) w = [] v = [] for i in range(n): w_, v_ = map(int, input().split()) w.append(w_) v.append(v_) dp = [[0]*(W+1) for i in range(n+1)] for i in range(n-1, -1, -1): for j in range(W+1): if j < w[i]: dp[i][j] = dp[i+1][j] else: dp[i][j] = max(dp[i+1][j], dp[i+1][...
s676893935
p03732
u127499732
1592874253
Python
Python (3.8.2)
py
Runtime Error
1960
3532276
659
def main(): n, w, *wv = map(int, open(0).read().split()) dp = [[0] * (w + 1) for _ in range(n + 1)] *q, = zip(*[iter(wv)] * 2) for i in range(1, n + 1): a, b = q[i - 1] if a > w: continue tmp = dp[i - 1][a] dp[i - 1][a] = max(dp[i - 1][a], b) dp[i...
s261960076
p03732
u127499732
1592873581
Python
Python (3.8.2)
py
Runtime Error
2279
3524260
479
def main(): n, w, *wv = map(int, open(0).read().split()) dp = [0] * (w + 1) for a, b in zip(*[iter(wv)] * 2): if a > w: continue tmp = dp[a] dp[a] = max(dp[a], b) dp = dp[:a] + [max(dp[i + a], dp[i] + b) if dp[i] else dp[i + a] for i in range(w + 1 - a)] ...
s416722332
p03732
u338824669
1592400434
Python
Python (3.4.3)
py
Runtime Error
1737
1974388
353
N,W=map(int,input().split()) weight,value=[0]*N,[0]*N for i in range(N): weight[i],value[i]=map(int,input().split()) dp=[[0]*(W+1) for _ in range(N+1)] for i in range(N): for w in range(W+1): if w>=weight[i]: dp[i+1][w]=max(dp[i][w-weight[i]]+value[i],dp[i][w]) else: dp...
s185894230
p03732
u707124227
1592149342
Python
Python (3.4.3)
py
Runtime Error
264
12520
486
n,W=map(int,input().split()) wv=[list(map(int,input().split()))] w0=wv[0][0]-1 wv[0][0]=1 # すべてのwからw0を引く for _ in range(n-1): w,v=list(map(int,input().split())) wv.append([w-w0,v]) import numpy as np dp=np.full((n+1,401),0,int) # dp[k][w]:k個で重さwでの最大価値 dp[0]=0 for w,v in wv: for i in range(n): dp[n-i][w:]=np.m...
s121405570
p03732
u707124227
1592149012
Python
Python (3.4.3)
py
Runtime Error
261
12436
486
n,W=map(int,input().split()) wv=[list(map(int,input().split()))] w0=wv[0][0]-1 wv[0][0]=1 # すべてのwからw0を引く for _ in range(n-1): w,v=list(map(int,input().split())) wv.append([w-w0,v]) import numpy as np dp=np.full((n+1,301),0,int) # dp[k][w]:k個で重さwでの最大価値 dp[0]=0 for w,v in wv: for i in range(n): dp[n-i][w:]=np.m...
s253960198
p03732
u464950331
1592107095
Python
Python (3.4.3)
py
Runtime Error
1037
15808
527
import numpy as np N, W = map(int, input().split()) weight = [] value = [] for _ in range(N): w, v = map(int, input().split()) value.append(v) weight.append(w) def solveDP(N, W, value, weight): dp = np.zeros((N+1, W+1)) for i in range(N): for w in range(W+1): if w >= weight[i...
s253328454
p03732
u316464887
1591158366
Python
Python (3.4.3)
py
Runtime Error
1478
100696
727
def main(): N, W = map(int, input().split()) l = [] w, v = map(int, input().split()) ww = w dp = [[[0] * (3*N) for _ in range(N+1) ]for _ in range(N)] dp[0][1][0] = v l.append((0, v)) for _ in range(N-1): w, v = map(int, input().split()) l.append((w-ww, v)) if W < ww:...
s723005807
p03732
u714642969
1589839017
Python
PyPy3 (2.4.0)
py
Runtime Error
2116
1823772
835
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF=10**18 MOD=10**9+7 input=lambda: sys.stdin.readline().rstrip() YesNo=lambda b: bool([print('Yes')] if b else print('No')) YESNO=lambda b: bool([print('YES')] if b else print('NO')) int1=lambda x:int(x)-1 def main(): N,W=map(int,input().split()) ...
s432507177
p03732
u714642969
1589838776
Python
PyPy3 (2.4.0)
py
Runtime Error
2113
1823772
820
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF=10**18 MOD=10**9+7 input=lambda: sys.stdin.readline().rstrip() YesNo=lambda b: bool([print('Yes')] if b else print('No')) YESNO=lambda b: bool([print('YES')] if b else print('NO')) int1=lambda x:int(x)-1 def main(): N,W=map(int,input().split()) ...
s942570381
p03732
u714642969
1589838508
Python
PyPy3 (2.4.0)
py
Runtime Error
1720
1824028
829
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF=10**18 MOD=10**9+7 input=lambda: sys.stdin.readline().rstrip() YesNo=lambda b: bool([print('Yes')] if b else print('No')) YESNO=lambda b: bool([print('YES')] if b else print('NO')) int1=lambda x:int(x)-1 def main(): N,W=map(int,input().split()) ...
s263812161
p03732
u519923151
1589835531
Python
Python (3.4.3)
py
Runtime Error
2125
524668
357
n,w = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] dp=[[ 0 for i in range(w+1)] for j in range(n+1)] for i in range(n): for j in range(ab[0][0],ab[0][0]+4): if j < ab[i][0]: dp[i+1][j] = dp[i][j] else: dp[i+1][j] = max((dp[i][j-ab[i][0]...
s143992198
p03732
u519923151
1589835445
Python
Python (3.4.3)
py
Runtime Error
2124
526488
356
n,w = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] dp=[[ 0 for i in range(w+1)] for j in range(n+1)] for i in range(n): for j in range(ab[0][1],ab[0][1]+4): if j < ab[i][0]: dp[i+1][j] = dp[i][j] else: dp[i+1][j] = max((dp[i][j-ab[i][0]]...
s385643640
p03732
u919025034
1589508606
Python
PyPy3 (2.4.0)
py
Runtime Error
1617
2004124
268
N,W=map(int,input().split()) dp=[[0]*(W+1) for i in range(N+1)] for i in range(1,N+1): w,v=map(int,input().split()) for j in range(W+1): if j-w>=0: dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v) else: dp[i][j]=dp[i-1][j] #print(dp) print(max(dp[-1]))
s579350828
p03732
u228223940
1589386514
Python
PyPy3 (2.4.0)
py
Runtime Error
187
39792
1163
n,w = map(int,input().split()) wv = [[int(i) for i in input().split()] for j in range(n)] wv.sort(key=lambda x:(x[0],-x[1])) #print(wv) #exit() #wv.sort() min_v = wv[0][0] cnt = 0 num = [0]*4 for i in range(n): num[wv[i][0] - wv[0][0]] +=1 #dp = [[[0 for i in range(n)] for j in range(n)] for k in range(n...
s718939170
p03732
u228223940
1589385824
Python
PyPy3 (2.4.0)
py
Runtime Error
221
50652
1125
n,w = map(int,input().split()) wv = [[int(i) for i in input().split()] for j in range(n)] wv.sort(key=lambda x:(x[0],-x[1])) #print(wv) #exit() #wv.sort() min_v = wv[0][0] cnt = 0 num = [0]*4 for i in range(n): num[wv[i][0] - wv[0][0]] +=1 dp = [[[0 for i in range(n)] for j in range(n)] for k in range(n)...
s513588713
p03732
u057109575
1588615202
Python
PyPy3 (2.4.0)
py
Runtime Error
1190
2004124
356
N, W = map(int, input().split()) X = [list(map(int, input().split())) for _ in range(N)] dp = [[0] * (W + 1) for _ in range(N + 1)] dp[0][0] = 0 for i in range(N): for j in range(W + 1): if j < X[i][0]: dp[i + 1][j] = dp[i][j] else: dp[i + 1][j] = max(dp[i][j], dp[i][j - X[i...
s795977800
p03732
u760794812
1587599558
Python
Python (3.4.3)
py
Runtime Error
1739
1974388
326
N,W = map(int,input().split()) dp = [[0]*(W+1) for _ in range(N+1)] WV = [] for _ in range(N): w,v = map(int,input().split()) WV.append([w,v]) for i in range(N): for w in range(W+1): if WV[i][0] <= w: dp[i+1][w] = max(dp[i][w - WV[i][0]]+WV[i][1],dp[i][w]) else: dp[i+1][w] = dp[i][w] print(dp[...
s731425021
p03732
u790710233
1586960595
Python
Python (3.4.3)
py
Runtime Error
17
3064
614
n, W = map(int, input().split()) dd = defaultdict(list) for i in range(n): weight, value = map(int, input().split()) dd[weight].append(value) for k in dd.keys(): dd[k].sort(reverse=True) a = min(dd.keys()) b, c, d = a+1, a+2, a+3 ans = 0 for w in range(len(dd[a])+1): for x in range(len(dd[b])+1): ...
s781860964
p03732
u790710233
1586921945
Python
PyPy3 (2.4.0)
py
Runtime Error
330
42220
605
n, w = map(int, input().split()) weights, values = zip(*[tuple(map(int, input().split()))for _ in range(n)]) min_w = min(weights)-1 weights = [weight-min_w for weight in weights] W_MAX = 4*200 dp = [[0]*(W_MAX+1) for _ in range(n+1)] for i in range(1, n+1): for k in reversed(range(1, n+1)): for j in range(1...
s241890926
p03732
u672475305
1586718451
Python
PyPy3 (2.4.0)
py
Runtime Error
1524
2004124
471
import sys sys.setrecursionlimit(10 ** 9) N,W = map(int,input().split()) w = [] v = [] for _ in range(N): w_, v_ = map(int,input().split()) w.append(w_) v.append(v_) # dp[i][j]:iまでを用いて、重みjの時の最大値 dp = [[0]*(W+1) for _ in range(N+1)] for i in range(N): for j in range(W+1): if w[i]<=j: ...
s622348283
p03732
u672475305
1586718378
Python
PyPy3 (2.4.0)
py
Runtime Error
1612
2004124
428
N,W = map(int,input().split()) w = [] v = [] for _ in range(N): w_, v_ = map(int,input().split()) w.append(w_) v.append(v_) # dp[i][j]:iまでを用いて、重みjの時の最大値 dp = [[0]*(W+1) for _ in range(N+1)] for i in range(N): for j in range(W+1): if w[i]<=j: dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]...
s438747733
p03732
u698919163
1586458677
Python
PyPy3 (2.4.0)
py
Runtime Error
1399
2004124
366
N,W = map(int,input().split()) w = [0]*N v = [0]*N for i in range(N): w[i],v[i] = map(int,input().split()) dp = [[0]*(W+1) for i in range(N+1)] for i in range(1,N+1): for j in range(W+1): if w[i-1] <= j: dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i-1]] + v[i-1]) else: dp[i][...
s412433522
p03732
u097317219
1586094595
Python
PyPy3 (2.4.0)
py
Runtime Error
2156
2029564
723
n,w = map(int,input().split()) wv = [list(map(int,input().split())) for _ in range(n)] #dp[i][j]はi番目まででj(価値の合計)になる重さの最小値 sum_value = 0 for i in range(n): sum_value += wv[i][1] dp = [[float("inf")]*(sum_value+1) for j in range(n)] for k in range(sum_value+1): if k == wv[0][1]: dp[0][k] = wv[0][0] for a in range(...
s160489815
p03732
u893063840
1583951619
Python
Python (3.4.3)
py
Runtime Error
645
31656
705
n, W = map(int, input().split()) wv = [list(map(int, input().split())) for _ in range(n)] dp = [[[-1] * (3 * n + 1) for _ in range(n + 1)] for _ in range(n + 1)] dp[0][0][0] = 0 w1 = wv[0][0] for i, (w, v) in enumerate(wv): for j in range(i + 1): for k in range(3 * n + 1): if dp[i][j][k] != -1...
s595747122
p03732
u498487134
1583793709
Python
PyPy3 (2.4.0)
py
Runtime Error
259
51184
1045
import sys input = sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) import bisect def main(): mod=10**9+7 N,W=MI() w=[0]*N v=[0]*N for i in range(N): w[i],v[i]=MI() w1=w[0] for i in range(N)...
s489860577
p03732
u067983636
1583452217
Python
PyPy3 (2.4.0)
py
Runtime Error
355
81244
1320
import sys input = sys.stdin.readline def read_values(): return map(int, input().split()) def read_list(): return list(read_values()) def func(N, mod): F = [1] for i in range(1, N + 1): F.append(F[-1] * i % mod) return F INV = {} def inv(a, mod): if a in INV: return IN...
s639764325
p03732
u067983636
1583452146
Python
PyPy3 (2.4.0)
py
Runtime Error
353
81116
1252
import sys input = sys.stdin.readline def read_values(): return map(int, input().split()) def read_list(): return list(read_values()) def func(N, mod): F = [1] for i in range(1, N + 1): F.append(F[-1] * i % mod) return F INV = {} def inv(a, mod): if a in INV: return IN...
s028413277
p03732
u067983636
1583451804
Python
PyPy3 (2.4.0)
py
Runtime Error
379
82140
1219
import sys input = sys.stdin.readline def read_values(): return map(int, input().split()) def read_list(): return list(read_values()) def func(N, mod): F = [1] for i in range(1, N + 1): F.append(F[-1] * i % mod) return F INV = {} def inv(a, mod): if a in INV: return IN...
s299484437
p03732
u067983636
1583451704
Python
PyPy3 (2.4.0)
py
Runtime Error
362
77404
1210
import sys input = sys.stdin.readline def read_values(): return map(int, input().split()) def read_list(): return list(read_values()) def func(N, mod): F = [1] for i in range(1, N + 1): F.append(F[-1] * i % mod) return F INV = {} def inv(a, mod): if a in INV: return IN...
s700932739
p03732
u067983636
1583451408
Python
PyPy3 (2.4.0)
py
Runtime Error
374
71900
1208
import sys input = sys.stdin.readline def read_values(): return map(int, input().split()) def read_list(): return list(read_values()) def func(N, mod): F = [1] for i in range(1, N + 1): F.append(F[-1] * i % mod) return F INV = {} def inv(a, mod): if a in INV: return IN...
s341170431
p03732
u113971909
1583260387
Python
Python (3.4.3)
py
Runtime Error
1710
213020
227
import sys input = sys.stdin.readline import numpy as np N,W=map(int, input().split()) dp = np.zeros(W+1, dtype=np.int) for i in range(N): wi,vi=map(int,input().split()) dp[wi:]=np.maximum(dp[wi:], dp[:-wi]+vi) print(dp[W])
s039267448
p03732
u223904637
1583083359
Python
Python (3.4.3)
py
Runtime Error
23
3064
582
n,w=map(int,input().split()) wv=[] v=[] for i in range(n): a,b=map(int,input().split()) wv.append([a,b]) v.append(b) v.sort(reverse=True) ans=0 w0=wv[0][0] for i in range(1,n+1): wp=w-w0*i if wp<0: continue elif wp>=3*i: ans=max(ans,sum(v[:i])) else: dp=[-1 for iii in...
s813193642
p03732
u223904637
1583083281
Python
Python (3.4.3)
py
Runtime Error
19
3064
559
n,w=map(int,input().split()) wv=[] v=[] for i in range(n): a,b=map(int,input().split()) wv.append([a,b]) v.append(b) v.sort(reverse=True) ans=0 w0=wv[0][0] for i in range(1,n+1): wp=w-w0*i if wp<0: continue elif wp>=3*i: ans=max(ans,sum(v[:i])) else: dp=[-1 for iii in...
s828918731
p03732
u760794812
1582680073
Python
Python (3.4.3)
py
Runtime Error
1994
1974388
519
import sys sys.setrecursionlimit(3000) N,W = map(int,input().split()) wv = [] for _ in range(N): w,v = map(int,input().split()) wv.append([w,v]) memo = [[0]*(W+1) for i in range(N+1)] def rec(n,uplimit_w): if memo[n][uplimit_w] > 0: return memo[n][uplimit_w] ans = 0 if n == N: return 0 elif wv[n][0]...
s389993282
p03732
u760794812
1582679883
Python
Python (3.4.3)
py
Runtime Error
1739
1974388
504
import sys sys.setrecursionlimit(3000) N,W = map(int,input().split()) wv = [] for _ in range(N): w,v = map(int,input().split()) wv.append([w,v]) memo = [[0]*(W+1) for i in range(N+1)] def rec(n,uplimit_w): if memo[n][uplimit_w] > 0: return memo[n][uplimit_w] ans = 0 if n == N: return 0 elif wv[n][0]...
s322050958
p03732
u760794812
1582678526
Python
Python (3.4.3)
py
Runtime Error
1769
1974388
465
N,W = map(int,input().split()) wv = [] for _ in range(N): w,v = map(int,input().split()) wv.append([w,v]) memo = [[0]*(W+1) for i in range(N+1)] def rec(n,uplimit_w): if memo[n][uplimit_w] > 0: return memo[n][uplimit_w] ans = 0 if n == N: return 0 elif wv[n][0] > uplimit_w: return rec(n+1,uplimi...
s010371671
p03732
u372144784
1582386741
Python
PyPy3 (2.4.0)
py
Runtime Error
1749
2004124
368
import sys readline = sys.stdin.buffer.readline N,W = map(int,readline().split()) #i:N,j:W,value:value dp = [[0]*(W+1) for i in range(N+1)] for i in range(1,N+1): w,v = map(int,readline().split()) for j in range(1,W+1): if j < w: dp[i][j] = dp[i-1][j] else: dp[i][j] = m...
s534129110
p03732
u372144784
1582386643
Python
PyPy3 (2.4.0)
py
Runtime Error
1763
2004124
417
import sys readline = sys.stdin.buffer.readline N,W = map(int,readline().split()) wv = [list(map(int,readline().split())) for i in range(N)] #i:N,j:W,value:value dp = [[0]*(W+1) for i in range(N+1)] for i in range(1,N+1): for j in range(1,W+1): if j < wv[i-1][0]: dp[i][j] = dp[i-1][j] ...
s561897488
p03732
u476604182
1581550413
Python
PyPy3 (2.4.0)
py
Runtime Error
1513
2004124
547
N, W = map(int,input().split()) ls = [] for i in range(N): w, v = map(int, input().split()) ls += [[w,v]] w1 = ls[0][0] for i in range(N): ls[i][0] -= w1 ans = 0 M = 3*N dp = [[-1]*(W+1) for i in range(N+1)] dp[0][0] = 0 for i in range(N): w, v = ls[i] for h in range(N,0,-1): for j in range(W,-1,-1): ...
s885293996
p03732
u476604182
1581550347
Python
PyPy3 (2.4.0)
py
Runtime Error
1440
2004124
548
N, W = map(int,input().split()) ls = [] for i in range(N): w, v = map(int, input().split()) ls += [[w,v]] w1 = ls[0][0] for i in range(N): ls[i][0] -= w1 ans = 0 M = 3*N dp = [[-1]*(W+1) for i in range(N+1)] dp[0][0] = 0 for i in range(N): w, v = ls[i] for h in range(N,-1,-1): for j in range(W,-1,-1): ...
s042071870
p03732
u298297089
1581130910
Python
PyPy3 (2.4.0)
py
Runtime Error
2115
2005656
624
n,w=map(int, input().split()) lim = min(w,10**5) dp = [0] * (lim+1) items = [] mod = 10**5 for _ in range(n): ww,v = map(int, input().split()) items.append((ww,v)) if ww > mod: continue for i in range(ww,lim+1)[::-1]: # print(i) if dp[i-ww] + v > dp[i]: dp[i] = dp[i-w...
s880159304
p03732
u298297089
1581129718
Python
Python (3.4.3)
py
Runtime Error
2125
2062324
293
n,w=map(int, input().split()) dp = [0] * (w+1) ans = 0 for _ in range(n): ww,v = map(int, input().split()) for i in range(ww,w+1)[::-1]: if dp[i-ww] + v > dp[i]: dp[i] = dp[i-ww] + v if ans < dp[i]: ans = dp[i] # print(dp) print(ans)
s059319129
p03732
u298297089
1581129710
Python
Python (3.4.3)
py
Runtime Error
17
2940
31
4 1 10 100 10 100 10 100 10 100
s824877272
p03732
u594244257
1580829438
Python
Python (3.4.3)
py
Runtime Error
2115
182388
1507
def solve(): N,W = map(int, input().split()) wv = [list(map(int, input().split())) for _ in range(N)] base_weight = wv[0][0] # sum_w = sum(map(lambda x:x[0], wv)) if base_weight > W: print(0) return wv_ = [[wv[i][0]-base_weight, wv[i][1]] for i in range(N)] dp_W = 3...
s397231910
p03732
u557494880
1580508640
Python
Python (3.4.3)
py
Runtime Error
55
9332
925
N,W = map(int,input().split()) w1,v = map(int,input().split()) d = [[-v],[],[],[]] for i in range(N-1): w,v = map(int,input().split()) x = w - w1 d[x].append(-v) d[0].sort() n0 = len(d[0]) d[1].sort() n1 = len(d[1]) d[2].sort() n2 = len(d[2]) d[3].sort() n3 = len(d[3]) d = [[[[0 for i in range(n3+1)] for j ...
s817050012
p03732
u760794812
1580443762
Python
Python (3.4.3)
py
Runtime Error
561
20384
885
import sys sys.setrecursionlimit(5000*5000) import numpy as np N,W = map(int,input().split()) wv = [tuple(map(int, input().split())) for i in range(0, N) ] # メモ化テーブル memo = np.zeros((N+1, W+1), dtype=int) def rec(n, uplimit_w): # 既に記録済みならその値を返すだけ if memo[n, uplimit_w] > 0: return memo[n, uplimit_w...
s142687800
p03732
u760794812
1580443672
Python
Python (3.4.3)
py
Runtime Error
540
15456
883
import sys sys.setrecursionlimit(500*500) import numpy as np N,W = map(int,input().split()) wv = [tuple(map(int, input().split())) for i in range(0, N) ] # メモ化テーブル memo = np.zeros((N+1, W+1), dtype=int) def rec(n, uplimit_w): # 既に記録済みならその値を返すだけ if memo[n, uplimit_w] > 0: return memo[n, uplimit_w] ...
s659527436
p03732
u760794812
1580443336
Python
PyPy3 (2.4.0)
py
Runtime Error
177
38256
841
import numpy as np N,W = map(int,input().split()) wv = [tuple(map(int, input().split())) for i in range(0, N) ] # メモ化テーブル memo = np.zeros((N+1, W+1), dtype=int) def rec(n, uplimit_w): # 既に記録済みならその値を返すだけ if memo[n, uplimit_w] > 0: return memo[n, uplimit_w] ans = 0 if n == N: return 0 ...
s455963122
p03732
u760794812
1580443181
Python
Python (3.4.3)
py
Runtime Error
578
21540
849
import numpy as np N,W = map(int,input().split()) wv = [tuple(map(int, input().split())) for i in range(0, N) ] # メモ化テーブル memo = np.zeros((N+1, W+1), dtype=int) def rec(n, uplimit_w): # 既に記録済みならその値を返すだけ if memo[n, uplimit_w] > 0: return memo[n, uplimit_w] ans = 0 if n == N: retur...
s052267529
p03732
u760794812
1580441979
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38384
935
import numpy as np N,W = map(int,input().split()) wv = [tuple(map(int, input().split())) for i in range(0, N) ] # メモ化テーブル memo = np.zeros((N+1, W+1), dtype=int) def rec(n, uplimit_w): # 既に記録済みならその値を返すだけ if memo[n, uplimit_w] > 0: return memo[n, uplimit_w] ans = 0 if n == N: retur...
s221862820
p03732
u760794812
1580441467
Python
PyPy3 (2.4.0)
py
Runtime Error
167
38256
939
import numpy as np N,W = map(int,input().split()) wv = [tuple(map(int, input().split())) for i in range(0, N) ] # メモ化テーブル #memo = np.zeros((N+1, W+1), dtype=int) def rec(n, uplimit_w): # 既に記録済みならその値を返すだけ # if memo[n, uplimit_w] > 0: # return memo[n, uplimit_w] ans = 0 if n == N: re...
s403598021
p03732
u353797797
1579277662
Python
Python (3.4.3)
py
Runtime Error
61
3316
895
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(ro...
s229373991
p03732
u445624660
1578919084
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38384
1129
# 典型ナップザックと思うと解けない(配列がとんでもないことになる) # 制約から考えると重さは4種類で合計最大100個なので「どの重さがいくつあるか」で探索できる n, w = map(int, input().split()) weight = {} first = list(map(int, input().split())) for i in range(first[0], first[0] + 4): weight[i] = [] weight[first[0]].append(first[1]) for _ in range(n - 1): w, v = map(int, input().split()...
s778174002
p03732
u989345508
1578429153
Python
Python (3.4.3)
py
Runtime Error
17
3064
788
n,w=map(int,input().split()) w_sub,v_sub=map(int,input().split()) w0=w_sub inf=1000000001 x=[[inf,v_sub],[inf],[inf],[inf]] for i in range(n-1): w_sub,v_sub=map(int,input().split()) w_sub-=w0 x[W_sub].append(v_sub) for i in range(4): x[i].sort(key=lambda x:-x) x[i][0]=0 l_sub=len(x[i]) for j...
s196058178
p03732
u989345508
1578422965
Python
Python (3.4.3)
py
Runtime Error
17
3192
929
n,w=map(int,input().split()) wv=[list(map(int,input().split())) for i in range(n)] wv.sort(key=lambda x:-x[1])#reverse wv.sort(key=lambda x:x[0]) #print(wv) w0=wv[0][0] x=[[0],[0],[0],[0]] for i in range(n): if wv[i][0]==w0: k=wv[i][1]+x[0][-1] l=len(x[0]) if l*w0<=w:x[0].append(k) elif ...
s123481511
p03732
u989345508
1578421245
Python
Python (3.4.3)
py
Runtime Error
19
3188
893
n,w=map(int,input().split()) wv=[list(map(int,input().split())) for i in range(n)] wv.sort(key=lambda x:-x[1]) wv.sort(key=lambda x:x[0]) #print(wv) w0=wv[0][0] x=[[0],[0],[0],[0]] for i in range(n): if wv[i][0]==w0: k=wv[i][1]+x[0][-1] l=len(x[0]) if l*w0<=w:x[0].append(k) elif wv[i][0]...
s509341009
p03732
u989345508
1578411680
Python
Python (3.4.3)
py
Runtime Error
2111
1974388
410
n,w=map(int,input().split()) wv=[list(map(int,input().split())) for i in range(n)] s=0 for i in range(n): s+=wv[i][1] x=[0]*(w+1) for i in range(n): x_sub=[0]*(w+1) if wv[i][0]<w+1: x_sub[wv[i][0]]=wv[i][1] for j in range(1,w+1): if x[j]!=0 and j+wv[i][0]<w+1: x_sub[j+wv[i][0...
s210701873
p03732
u945181840
1576187968
Python
Python (3.4.3)
py
Runtime Error
198
15800
315
import sys import numpy as np read = sys.stdin.read N, W, *wv = map(int, read().split()) dp = np.zeros((W + 1, N + 1), np.int64) idx = 1 for w, v in zip(*[iter(wv)] * 2): dp[:, idx] = dp[:, idx - 1] if w <= W: dp[w:, idx] = np.maximum(dp[w:, idx], dp[:-w, idx] + v) idx += 1 print(dp[-1, -1])
s725876751
p03732
u945181840
1576187826
Python
Python (3.4.3)
py
Runtime Error
157
15796
328
import sys import numpy as np read = sys.stdin.read N, W, *wv = map(int, read().split()) dp = np.zeros((W + 1, N + 1), np.int64) idx = 1 for w, v in zip(*[iter(wv)] * 2): if w > W: continue dp[:, idx] = dp[:, idx - 1] dp[w:, idx] = np.maximum(dp[w:, idx], dp[:-w, idx] + v) idx += 1 print(dp[...
s771283956
p03732
u945181840
1576186364
Python
Python (3.4.3)
py
Runtime Error
159
15800
335
import sys import numpy as np read = sys.stdin.read N, W, *wv = map(int, read().split()) dp = np.zeros((W + 1, N + 1), np.int64) idx = 1 for w, v in zip(*[iter(wv)] * 2): if w > W: continue dp[:, idx] = dp[:, idx - 1] dp[w:, idx] = np.maximum(dp[w:, idx], dp[:W - w + 1, idx] + v) idx += 1 pr...
s230788808
p03732
u945181840
1576186109
Python
Python (3.4.3)
py
Runtime Error
164
15820
303
import sys import numpy as np read = sys.stdin.read N, W, *wv = map(int, read().split()) dp = np.zeros((W + 1, N + 1), np.int64) idx = 1 for w, v in zip(*[iter(wv)] * 2): dp[:, idx] = dp[:, idx - 1] dp[w:, idx] = np.maximum(dp[w:, idx], dp[:W - w + 1, idx] + v) idx += 1 print(dp[-1, -1])
s815878216
p03732
u829859091
1575772976
Python
Python (3.4.3)
py
Runtime Error
1723
1974388
686
N, W = map(int, input().split()) w, v = [], [] for i in range(N): wi, vi = map(int, input().split()) w.append(wi) v.append(vi) # for i in range(N): # wi, vi = map(int, input().split()) # if i == 0: # w1 = wi # w.append(wi-w1) # v.append(vi) # W -= w1*N # dp[i+1][j]: 重さjまで入れていい状況で,...