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
s140261347
p02315
u494314211
1479020707
Python
Python3
py
Runtime Error
0
0
339
l=[] n,W=list(map(int,input().split())) for i in range(n): item=list(map(int,input().split)) l.append([item[1],item[0]]) # n=4 # l=[[2,3],[1,2],[3,4],[2,2]] #w,v # W=5 print(l) def solve(i,w): if i==n or w<0: return(0) elif w-l[i][0]<0: return(0) else: return(max(solve(i+1,w),l[i][1]+solve(i+1,w-l[i][0])))...
s974167506
p02315
u494314211
1479021064
Python
Python3
py
Runtime Error
0
0
339
l=[] n,W=list(map(int,input().split())) for i in range(n): item=list(map(int,input().split)) l.append([item[1],item[0]]) # n=4 # l=[[2,3],[1,2],[3,4],[2,2]] #w,v # W=5 print(l) def solve(i,w): if i==n or w<0: return(0) elif w-l[i][0]<0: return(0) else: return(max(solve(i+1,w),l[i][1]+solve(i+1,w-l[i][0])))...
s792593372
p02315
u494314211
1479021929
Python
Python3
py
Runtime Error
0
0
390
l=[] n,W=list(map(int,input().split())) for i in range(n): item=list(map(int,input().split)) l.append([item[1],item[0]]) # n=4 # l=[[2,3],[1,2],[3,4],[2,2]] #w,v # W=5 print(l) def solve(i,w): if i==n: return(0) elif w-l[i][0]<0: return(0) else: a=solve(i+1,w) b=l[i][1]+solve(i+1,w-l[i][0]) if b>a: ...
s279351420
p02315
u494314211
1479021975
Python
Python3
py
Runtime Error
0
0
393
l=[] n,W=input().split() n=int(n) W=int(W) for i in range(n): item=list(map(int,input().split)) l.append([item[1],item[0]]) # n=4 # l=[[2,3],[1,2],[3,4],[2,2]] #w,v # W=5 print(l) def solve(i,w): if i==n: return(0) elif w-l[i][0]<0: return(0) else: a=solve(i+1,w) b=l[i][1]+solve(i+1,w-l[i][0]) if b>a: ...
s341078393
p02315
u494314211
1479022059
Python
Python3
py
Runtime Error
0
0
384
l=[] n,W=input().split() n=int(n) W=int(W) for i in range(n): item=list(map(int,input().split)) l.append([item[1],item[0]]) # n=4 # l=[[2,3],[1,2],[3,4],[2,2]] #w,v # W=5 def solve(i,w): if i==n: return(0) elif w-l[i][0]<0: return(0) else: a=solve(i+1,w) b=l[i][1]+solve(i+1,w-l[i][0]) if b>a: print(...
s550261908
p02315
u494314211
1479022099
Python
Python3
py
Runtime Error
0
0
363
l=[] n,W=input().split() n=int(n) W=int(W) for i in range(n): item=list(map(int,input().split)) l.append([item[1],item[0]]) # n=4 # l=[[2,3],[1,2],[3,4],[2,2]] #w,v # W=5 def solve(i,w): if i==n: return(0) elif w-l[i][0]<0: return(0) else: a=solve(i+1,w) b=l[i][1]+solve(i+1,w-l[i][0]) if b>a: return...
s709334575
p02315
u494314211
1479022925
Python
Python3
py
Runtime Error
0
0
458
l=[] n,W=input().split() n=int(n) W=int(W) for i in range(n): item=list(map(int,input().split())) l.append([item[1],item[0]]) dp=[[False for j in range(W)] for i in range(n)] def solve(i,w): if dp[i][w]==False: if i==n: res=(0) elif w-l[i][0]<0: res=(solve(i+1,w)) else: a=solve(i+1,w) b=l[i][1]+...
s233729152
p02315
u494314211
1479023247
Python
Python3
py
Runtime Error
0
0
458
l=[] n,W=input().split() n=int(n) W=int(W) for i in range(n): item=list(map(int,input().split())) l.append([item[1],item[0]]) dp=[[False for j in range(n)] for i in range(W)] def solve(i,w): if dp[i][w]==False: if i==n: res=(0) elif w-l[i][0]<0: res=(solve(i+1,w)) else: a=solve(i+1,w) b=l[i][1]+...
s430514171
p02315
u494314211
1479023370
Python
Python3
py
Runtime Error
0
0
469
l=[] n,W=input().split() n=int(n) W=int(W) for i in range(n): item=list(map(int,input().split())) l.append([item[1],item[0]]) dp=[[False for j in range(W)+1] for i in range(n)] print(dp) def solve(i,w): if dp[i][w]==False: if i==n: res=(0) elif w-l[i][0]<0: res=(solve(i+1,w)) else: a=solve(i+1,w) ...
s264211584
p02315
u843404779
1493780260
Python
Python3
py
Runtime Error
0
0
563
import numpy as np N, W = list(map(int, input().split())) v_list = list() w_list = list() for _ in range(N): v, w = list(map(int, input().split())) v_list.append(v) w_list.append(w) sum_v_table = np.zeros([N+1, W+1], int) for i in range(1, N+1): item = v_list[i-1], w_list[i-1] for w in range(1, ...
s892831055
p02315
u837811962
1497161551
Python
Python3
py
Runtime Error
0
0
332
N,W = map(int,input().split()) v = [0]*N;w = [0]*N for i in range(N): v[i],w[i] = map(int,input().split()) value = [0 for i in range(W+1)] for i in range(N): for j in range(W+1,-1,-1): if j<w[i]: value[j] = value[j] else: value[j] = max(value[j],value[j-w[i]]+v[i]) pri...
s364917740
p02315
u321712183
1497362933
Python
Python3
py
Runtime Error
0
0
297
N, W = map(int, raw_input().split()) v = [0] * N w = [0] * N for i in range(N): v[i], w[i] = map(int, raw_input().split()) def rec(i, j): if i == N: res = 0 elif j < w[i]: res = rec(i + 1, j) else: res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]) return res print(rec(0, W)) [/sourcecode]
s336174681
p02315
u321712183
1497362954
Python
Python
py
Runtime Error
0
0
297
N, W = map(int, raw_input().split()) v = [0] * N w = [0] * N for i in range(N): v[i], w[i] = map(int, raw_input().split()) def rec(i, j): if i == N: res = 0 elif j < w[i]: res = rec(i + 1, j) else: res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]) return res print(rec(0, W)) [/sourcecode]
s808652372
p02315
u321712183
1507495641
Python
Python3
py
Runtime Error
0
0
360
N, W = map(int,input().split()) v = [0] * N w = [0] * N dp = [[0 for i in range(W + 1)] for j in range(N + 1)] for i in range(N): v[i], w[i] = map(int, raw_input().split()) 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 +...
s172499247
p02315
u379644729
1509361450
Python
Python3
py
Runtime Error
0
0
469
N, W = map(int, input().split(" ")) ??? v = [0] * N w = [0] * N dp = [[-1 for i in range(W + 1)] for j in range(N + 1)] ??? for i in range(N): v[i], w[i] = map(int, input().split(" ")) ??? def rec(i, j): if dp[i][j] != -1: return dp[i][j] ??? if i == N: res = 0 elif j < w[i]: re...
s748750038
p02315
u379644729
1509361499
Python
Python3
py
Runtime Error
0
0
469
N, W = map(int, input().split(" ")) ??? v = [0] * N w = [0] * N dp = [[-1 for i in range(W + 1)] for j in range(N + 1)] ??? for i in range(N): v[i], w[i] = map(int, input().split(" ")) ??? def rec(i, j): if dp[i][j] != -1: return dp[i][j] ??? if i == N: res = 0 elif j < w[i]: re...
s241311528
p02315
u957470671
1513615208
Python
Python3
py
Runtime Error
0
0
298
# 0-1 Knapsack Problem N, W = [int(x) for x in input().split()] items = [] for i in range(N): items.append(tuple(int(x) for x in input().split())) DP = [0] * (W+1) for i in range(N): v, w = items[i] for j in range(W, w-1, -1): DP[j] = max(DP[j], v + DP[j-w]) print(DP[-1][-1])
s492925295
p02315
u904185678
1514390375
Python
Python3
py
Runtime Error
0
0
1157
import copy def main(): [N,W]=input().split(" ")'''read from keyboard and put all the item to box''' N=int(N) W=int(W) box=[] for i in range(N): [vi,wi]=input().split(" ") box.append([float(vi),float(wi)]) assemblebox=[]'''creat a set of full permutation of input. using ...
s090088736
p02315
u904185678
1514390429
Python
Python3
py
Runtime Error
0
0
1162
import copy def main(): [N,W]=input().split(" ")'''read from keyboard and put all the item to box''' N=int(N) W=int(W) box=[] for i in range(N): [vi,wi]=input().split(" ") box.append([float(vi),float(wi)]) assemblebox=[]'''creat a set of full permutation of input. using ...
s696336271
p02315
u904185678
1514390461
Python
Python
py
Runtime Error
0
0
1162
import copy def main(): [N,W]=input().split(" ")'''read from keyboard and put all the item to box''' N=int(N) W=int(W) box=[] for i in range(N): [vi,wi]=input().split(" ") box.append([float(vi),float(wi)]) assemblebox=[]'''creat a set of full permutation of input. using ...
s385050623
p02315
u904185678
1514390542
Python
Python
py
Runtime Error
0
0
1177
import copy def main(): [N,W]=input().split(" ") '''read from keyboard and put all the item to box''' N=int(N) W=int(W) box=[] for i in range(N): [vi,wi]=input().split(" ") box.append([float(vi),float(wi)]) assemblebox=[] '''creat a set of full permutation of inp...
s800145658
p02315
u904185678
1514390640
Python
Python
py
Runtime Error
0
0
1012
import copy def main(): [N,W]=input().split(" ") N=int(N) W=int(W) box=[] for i in range(N): [vi,wi]=input().split(" ") box.append([float(vi),float(wi)]) assemblebox=[] assemblebox=permutations(N,box,assemblebox,[]) maximum=0 for i in range(len(assemblebox))...
s261589057
p02315
u904185678
1514390723
Python
Python
py
Runtime Error
0
0
1000
def main(): [N,W]=input().split(" ") N=int(N) W=int(W) box=[] for i in range(N): [vi,wi]=input().split(" ") box.append([float(vi),float(wi)]) assemblebox=[] assemblebox=permutations(N,box,assemblebox,[]) maximum=0 for i in range(len(assemblebox)): we...
s682150411
p02315
u904185678
1514402349
Python
Python3
py
Runtime Error
0
0
709
import numpy as np def main(): [N,W]=input().split(" ") N=int(N) W=int(W) inputset=[] for i in range(N): [vi,wi]=input().split(" ") inputset.append([int(vi),int(wi)]) graph=np.zeros([N+1,W+1]) for i in range(N): for j in range(W+1): if(inputset[i][1]>j):...
s608278354
p02315
u904185678
1514402382
Python
Python3
py
Runtime Error
0
0
701
import numpy as np def main(): [N,W]=input().split(" ") N=int(N) W=int(W) inputset=[] for i in range(N): [vi,wi]=input().split(" ") inputset.append([int(vi),int(wi)]) graph=np.zeros([N+1,W+1]) for i in range(N): for j in range(W+1): if(inputset[i][1]>j):...
s641968176
p02315
u904185678
1514402397
Python
Python3
py
Runtime Error
0
0
707
import numpy as np def main(): [N,W]=input().split(" ") N=int(N) W=int(W) inputset=[] for i in range(N): [vi,wi]=input().split(" ") inputset.append([int(vi),int(wi)]) graph=np.zeros([N+1,W+1]) '''for i in range(N): for j in range(W+1): if(inputset[i][1]>...
s854739084
p02315
u904185678
1514402425
Python
Python3
py
Runtime Error
0
0
226
import numpy as np def main(): [N,W]=input().split(" ") N=int(N) W=int(W) inputset=[] for i in range(N): [vi,wi]=input().split(" ") inputset.append([int(vi),int(wi)]) print(13) main()
s104035012
p02315
u904185678
1514402439
Python
Python3
py
Runtime Error
0
0
55
import numpy as np def main(): print(13) main()
s081132571
p02315
u904185678
1514402497
Python
Python3
py
Runtime Error
0
0
691
def main(): [N,W]=input().split(" ") N=int(N) W=int(W) inputset=[] for i in range(N): [vi,wi]=input().split(" ") inputset.append([int(vi),int(wi)]) graph=np.zeros([N+1,W+1]) for i in range(N): for j in range(W+1): if(inputset[i][1]>j): g...
s977901656
p02315
u904185678
1514402539
Python
Python3
py
Runtime Error
0
0
54
import numpy as np def main(): print(13) main()
s733530168
p02315
u904185678
1514402559
Python
Python3
py
Runtime Error
0
0
48
import numpy def main(): print(13) main()
s275917620
p02315
u904185678
1514402587
Python
Python3
py
Runtime Error
0
0
48
import numpy def main(): print(13) main()
s351110222
p02315
u904185678
1514402613
Python
Python3
py
Runtime Error
0
0
48
import scipy def main(): print(13) main()
s409780748
p02315
u996738299
1518505108
Python
Python3
py
Runtime Error
0
0
466
N,W = map(int,input().split()) val = [] wei = [] for i in range(N): a,b = map(int,input().split()) val.append(a) wei.append(b) import numpy as np #DPテーブル dp = np.zeros((N+1,W+1)) #初期化 for j in range(W+1): dp[0][j] = 0 #DP計算 for i in range(N): for w in range(W+1): if(w >= wei[i]): ...
s407974383
p02315
u834139744
1521905569
Python
Python3
py
Runtime Error
0
0
409
N, W = map(int, input().split()) dp = [[0] * W for _ in range(N+1)] weights = list() values = list() for _ in range(N): w, v = map(int, input().split()) weights.append(w) values.append(v) for i in range(N): for w in range(W): if w >= weights[i]: dp[i+1][w] = max(dp[i][w-weights[i]]...
s074355856
p02315
u185486509
1523808113
Python
Python3
py
Runtime Error
0
0
463
import numpy as np MAX_N = 100 MAX_W = 10000 dp = np.ones((MAX_N+1, MAX_W+1)) * (-1) def rec(i, j): if dp[i][j] >= 0: return dp[i][j] if i == n: res = 0 elif j < vw[i][1]: res = rec(i+1, j) else: res = max(rec(i+1, j), rec(i+1, j-vw[i][1])+vw[i][0]) dp[i][j] = res ...
s189992160
p02315
u185486509
1523808343
Python
Python3
py
Runtime Error
0
0
463
import numpy as np MAX_N = 100 MAX_W = 10000 dp = np.ones((MAX_N+1, MAX_W+1)) * (-1) def rec(i, j): if dp[i][j] >= 0: return dp[i][j] if i == n: res = 0 elif j < vw[i][1]: res = rec(i+1, j) else: res = max(rec(i+1, j), rec(i+1, j-vw[i][1])+vw[i][0]) dp[i][j] = res ...
s700503203
p02315
u185486509
1523808585
Python
Python3
py
Runtime Error
0
0
500
import numpy as np MAX_N = 100 MAX_W = 10000 dp = np.ones((MAX_N+1, MAX_W+1)) * (-1) def rec(i, j): if dp[i][j] >= 0: return dp[i][j] if i == n: res = 0 elif j < vw[i][1]: res = rec(i+1, j) else: res = max(rec(i+1, j), rec(i+1, j-vw[i][1])+vw[i][0]) dp[i][j] = res ...
s515525768
p02315
u185486509
1523809043
Python
Python3
py
Runtime Error
0
0
502
MAX_N = 100 MAX_W = 10000 dp = [[-1 for j in range(MAX_W+1)] for i in range(MAX_N+1)] def rec(i, j): if dp[i][j] >= 0: return dp[i][j] if i == n: res = 0 elif j < vw[i][1]: res = rec(i+1, j) else: res = max(rec(i+1, j), rec(i+1, j-vw[i][1])+vw[i][0]) dp[i][j] = res...
s269374838
p02315
u185486509
1523810003
Python
Python3
py
Runtime Error
0
0
556
def rec(i, j): if dp[i][j] >= 0: return dp[i][j] if i == n: res = 0 elif j < vw[i][1]: res = rec(i+1, j) else: res = max(rec(i+1, j), rec(i+1, j-vw[i][1])+vw[i][0]) dp[i][j] = res return res def solve(): n, w = (int(s) for s in input().split()) vw = list...
s229338963
p02315
u185486509
1523810226
Python
Python3
py
Runtime Error
0
0
561
def rec(i, j): if dp[i][j] >= 0: return dp[i][j] if i == n: res = 0 elif j < vw[i][1]: res = rec(i+1, j) else: res = max(rec(i+1, j), rec(i+1, j-vw[i][1])+vw[i][0]) dp[i][j] = res return res def solve(): n, w = tuple(int(s) for s in input().split()) vw =...
s467091653
p02315
u185486509
1523811474
Python
Python3
py
Runtime Error
0
0
602
import sys sys.setrecursionlimit(10000) def rec(i, j): if dp[i][j] >= 0: return dp[i][j] if i == n: res = 0 elif j < vw[i][1]: res = rec(i+1, j) else: res = max(rec(i+1, j), rec(i+1, j-vw[i][1])+vw[i][0]) dp[i][j] = res return res def solve(): n, w = tuple(...
s484933739
p02315
u185486509
1523811511
Python
Python3
py
Runtime Error
0
0
603
import sys sys.setrecursionlimit(100000) def rec(i, j): if dp[i][j] >= 0: return dp[i][j] if i == n: res = 0 elif j < vw[i][1]: res = rec(i+1, j) else: res = max(rec(i+1, j), rec(i+1, j-vw[i][1])+vw[i][0]) dp[i][j] = res return res def solve(): n, w = tuple...
s480967283
p02315
u185486509
1523811613
Python
Python3
py
Runtime Error
0
0
604
import sys sys.setrecursionlimit(100000) def rec(i, j): if dp[i][j] >= 0: return dp[i][j] if i == n: res = 0 elif j < vw[i][1]: res = rec(i+1, j) else: res = max(rec(i+1, j), rec(i+1, j-vw[i][1])+vw[i][0]) dp[i][j] = res return res def solve(): n, w = tuple...
s005568402
p02315
u185486509
1523811713
Python
Python3
py
Runtime Error
0
0
593
import sys sys.setrecursionlimit(100000) MAX_N = 100 MAX_W = 10000 dp = list(list(-1 for j in range(MAX_W+1)) for i in range(MAX_N+1)) def rec(i, j): if dp[i][j] >= 0: return dp[i][j] if i == n: res = 0 elif j < vw[i][1]: res = rec(i+1, j) else: res = max(rec(i+1,...
s624966778
p02315
u724548524
1525836144
Python
Python3
py
Runtime Error
0
0
1775
import sys def cv(w, p, vi, wi): global value w0 = 0 v0 = 0 for i in range(len(vi)): w0 += wi[i] if w0 >= w:def cv(w, p, vi, wi): global value # print(value) # print("{} {} {} {}".format(w, p, vi, wi)) w0 = 0 v0 = 0 for i in range(len(vi)): w0 += wi[i] ...
s521177080
p02315
u150984829
1525927628
Python
Python3
py
Runtime Error
0
0
155
N,W=map(int,input().split()) C=[0]*-~W for _ in[0]*N: v,w=mpa(int,input().split()) for i in range(W,w-1,-1): t=v+C[i-w] if t>C[i]:C[j]=t print(C[W])
s849331848
p02315
u150984829
1525927644
Python
Python3
py
Runtime Error
0
0
155
N,W=map(int,input().split()) C=[0]*-~W for _ in[0]*N: v,w=map(int,input().split()) for i in range(W,w-1,-1): t=v+C[i-w] if t>C[i]:C[j]=t print(C[W])
s187097400
p02315
u399892098
1526274486
Python
Python3
py
Runtime Error
0
0
458
import numpy as np num_line,max_weight = map(int,input().split()) dp = np.zeros([num_line+1,max_weight+1]) fac = [] for i in range(num_line): v,w = map(int,input().split()) fac.append([v,w]) for i in range(1,num_line + 1): for j in range(1,max_weight+1): if(j >= fac[i-1][1]): dp[i][j] ...
s197983817
p02315
u121616304
1528293653
Python
Python3
py
Runtime Error
20
5644
419
N,W=map(int,input().split()) items=[] for i in range(N): items.append(list(map(int,input().split()))) dp = [[0 for i in range(100)] for j in range(100)] for i in range(N): dp[i][0]=0 for i in range(N): for w in range(W+1): if w>=items[i][1]: dp[i+1][w]=max(dp[i][w-items[i][1...
s935391934
p02315
u121616304
1528293864
Python
Python3
py
Runtime Error
240
18248
420
N,W=map(int,input().split()) items=[] for i in range(N): items.append(list(map(int,input().split()))) dp = [[0 for i in range(10000)] for j in range(100)] for i in range(N): dp[i][0]=0 for i in range(N): for w in range(W+1): if w>=items[i][1]: dp[i+1][w]=max(dp[i][w-items[i]...
s118833630
p02315
u121616304
1528293919
Python
Python3
py
Runtime Error
240
18248
420
N,W=map(int,input().split()) items=[] for i in range(N): items.append(list(map(int,input().split()))) dp = [[0 for i in range(10000)] for j in range(100)] for i in range(N): dp[i][0]=0 for i in range(N): for w in range(W+1): if w>=items[i][1]: dp[i+1][w]=max(dp[i][w-items[i]...
s876774476
p02315
u121616304
1528293926
Python
Python3
py
Runtime Error
550
25336
420
N,W=map(int,input().split()) items=[] for i in range(N): items.append(list(map(int,input().split()))) dp = [[0 for i in range(10001)] for j in range(100)] for i in range(N): dp[i][0]=0 for i in range(N): for w in range(W+1): if w>=items[i][1]: dp[i+1][w]=max(dp[i][w-items[i]...
s377198848
p02315
u138224929
1528445405
Python
Python3
py
Runtime Error
30
6776
758
#問題2 #https://qiita.com/drken/items/a5e6fe22863b7992efdb #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=jp n, w = map(int,input().split()) value = [] weight = [] for i in range(n): val,wei = map(int,input().split()) value.append(val) weight.append(wei) #dp i <= 110, w <= 1010 d...
s784605217
p02315
u650712316
1528691008
Python
Python3
py
Runtime Error
20
5600
595
N,W = map(int,input().split()) value = [0] weight = [0] for i in range(N): v,w = map(int,input().split()) value.append(v) weight.append(w) dp = [[0]*(N+10) for _ in range(W+10)] #dp[k][w]はk番目までの荷物を使ってw以内に抑えた時の最大値 #dp[0][_] = dp[_][w] = 0と定義する(荷物は1番目、2番目、・・・、N番目と定義する) for w in range(1,W+2): for k in ra...
s475012896
p02315
u650712316
1528691034
Python
Python3
py
Runtime Error
20
5604
405
N,W = map(int,input().split()) value = [0] weight = [0] for i in range(N): v,w = map(int,input().split()) value.append(v) weight.append(w) dp = [[0]*(N+10) for _ in range(W+10)] for w in range(1,W+2): for k in range(1,N+1): if weight[k] > w: dp[k][w] = dp[k-1][w] else: ...
s678438427
p02315
u955541348
1528713582
Python
Python3
py
Runtime Error
0
0
318
N, W = map(int,input().split()) A = [] B = [[0 for j in range(W)]] for i in range(N): A.append(list(map(int, input().split()))) B.append([0 for j in range(W)]) for i in range(N): for j in range(W): if j >= A[i][1]: B[i + 1][j] = max(B[i][j], B[i][j - A[i][1]] + A[i][0]) print(B[N][W])
s425543425
p02316
u209989098
1532052016
Python
Python3
py
Runtime Error
0
0
182
N,W = map(int, input().split()) dp = [0]*(W+1) for i in range(N): a,b = map(int,input().split()) for j in range(b,W+1,b): x = a + dp[j-b] if x >= dp[j]: dp = x print(W+1)
s621645524
p02316
u209989098
1532052299
Python
Python3
py
Runtime Error
0
0
189
N,W = map(int, input().split()) dp = [0]*(W+1) for i in range(N): a,b = map(int,input().split()) for j in range(b,W+1,b): x = a + dp[j-b] if x >= dp[j]: dp[j] = x print(dp[W+1])
s070427470
p02316
u134812425
1541124542
Python
Python3
py
Runtime Error
0
0
1277
import bisect import collections import heapq import itertools import math import string import sys from itertools import chain, takewhile import numpy as np def read( f, *shape, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace) ): def read_word(): return f("".join(takewhile(lambd...
s834035281
p02316
u567380442
1427804569
Python
Python3
py
Runtime Error
0
0
417
from sys import stdin readline = stdin.readline n, total_wait = map(int, readline().split()) value_wait = [list(map(int, readline().split())) for _ in range(n)] value_wait.sort(key=operator.itemgetter(1), reverse=True) dp = [0] * (total_wait + 1) for ni, (v, w) in enumerate(value_wait): for tw in range(w, total...
s030237078
p02316
u551083572
1462626875
Python
Python3
py
Runtime Error
60
8352
732
# coding: utf-8 from __future__ import print_function from __future__ import unicode_literals from __future__ import division from __future__ import absolute_import def array2d(row, col, init = None): return [[init for _ in range(col)] for _ in range(row)] N, W = map(int, input().split(" ")) v = [] w = [] for i ...
s434765745
p02316
u551083572
1462627000
Python
Python3
py
Runtime Error
20
7732
799
# coding: utf-8 from __future__ import print_function from __future__ import unicode_literals from __future__ import division from __future__ import absolute_import def array2d(row, col, init = None): return [[init for _ in range(col)] for _ in range(row)] N, W = map(int, input().split(" ")) v = [] w = [] for i ...
s298254063
p02316
u252368621
1482162963
Python
Python3
py
Runtime Error
50
8288
546
def dfs_dp(w,v,n,W,index,dp): if (dp[index][W] != -1): return dp[index][W] if index==n: return 0 if W<w[index]: return dfs_dp(w,v,n,W,index+1,dp) ret=max(dfs_dp(w,v,n,W,index+1,dp),v[index]+dfs_dp(w,v,n,W-w[index],index+1,dp),v[index]+dfs_dp(w,v,n,W-w[index],index,dp)) dp[index][W]=ret ...
s688476284
p02316
u197615397
1506341860
Python
Python3
py
Runtime Error
0
0
267
N, W = map(int, input().split()) dp = [0] + [-1]*(W+1) for i in range(N): v, w = map(int, input().split()) for j in range(0, W-w+1): if dp[j] > -1 and dp[j+w] < dp[j] + v: dp[j+w] = dp[j] + v print(max(dp))
s922977073
p02316
u938045879
1522657429
Python
Python3
py
Runtime Error
20
5616
638
n,w = map(int, input().split()) values = [0] weights = [0] counter=0 rest = 0 for i in range(n): v,weight = map(int, input().split()) values.append(v) weights.append(weight) dp=[[0 for i in range(w+1)]for j in range(v+1)] for i in range(1, n+1): for j in range(1, w+1): rest = j counter...
s273095605
p02317
u209989098
1532165569
Python
Python3
py
Runtime Error
0
0
204
import bisect a = int(input()) b = [int(input()) in d in range(a)] c = [b[1]] for i in b[1:]: if c[-1] < i: c.append(i) else: c[bisect.bisect_left(c,i)] = i print(len(L))
s772035730
p02317
u209989098
1532165609
Python
Python3
py
Runtime Error
0
0
204
import bisect a = int(input()) b = [int(input()) in d in range(a)] c = [b[1]] for i in b[1:]: if c[-1] < i: c.append(i) else: c[bisect.bisect_left(c,i)] = i print(len(c))
s747185990
p02317
u088372268
1534744578
Python
Python3
py
Runtime Error
20
5640
334
import bisect INF = 1 << 20 def main(): n = int(input()) a = [int(input()) for i in range(n)] dp = [INF for i in range(n+1)] for i in range(1, n+1): idx = bisect.bisect_left(dp, a[i-1]) dp[idx] = a[i-1] ans = bisect.bisect_left(dp, INF) print(ans) if __name__ == '__main__'...
s869775719
p02317
u467648242
1545837005
Python
Python3
py
Runtime Error
0
0
356
n = int(input()) in_list = [] for i in range(n): in_list.append(list(map(int, input().split()))) matrices = [["0" for _ in range(n)] for _ in range(n)] for i in range(n): inp = in_list[i] u = inp[0] k = inp[1] for j in range(k): m = inp[j+2] matrices[i][m-1] = "1" for i in range(n...
s853891152
p02317
u567380442
1427862399
Python
Python3
py
Runtime Error
30
6736
266
from sys import stdin import bisect readline = stdin.readline dp = [-float('inf')] n = int(readline()) a = (int(readline()) for _ in range(n)) for ai in a: if dp[-1] < ai: dp.append(ai) else: dp[bisect.bisect(dp, ai)] = ai print(len(dp) - 1)
s372976869
p02317
u633068244
1432611576
Python
Python
py
Runtime Error
0
0
361
import bisect def lis(A): n = len(A) L = [0] * n L[0] = A[0] length = 1 for i in xrange(1, n): if L[length - 1] < A[i]: L[length] = A[i] length += 1 else: L[bisect.bisect_left(L, A[i])] = A[i] return length n = int(raw_input()) a = [int(raw_...
s987355139
p02317
u260980560
1465193369
Python
Python
py
Runtime Error
10
6444
174
from bisect import * n = input() dp = [n+1]*(n+1) dp[0] = -1 for i in xrange(n): a = input() idx = bisect(dp, a-1) dp[idx] = min(a, dp[idx]) print bisect(dp, n)-1
s728408029
p02317
u797673668
1468909154
Python
Python3
py
Runtime Error
20
7716
158
n = int(input()) array = [int(input()) for _ in range(n)] dp = [0] * (max(array) + 1) for a in array: dp[a] = max(dp[a], max(dp[:a]) + 1) print(max(dp))
s457304514
p02317
u252368621
1482305600
Python
Python3
py
Runtime Error
20
7764
513
def dfs(index,prev,n,a,dp): if dp[index][prev] != -1: return dp[index][prev] if index==n: return 0 if prev != -1 and a[prev]>=a[index]: return dfs(index+1,prev,n,a,dp) ren=max(dfs(index+1,prev,n,a,dp),dfs(index+1,index,n,a,dp)+1) dp[index][prev]=ren return ren n=int(i...
s006762063
p02317
u854976463
1490870676
Python
Python
py
Runtime Error
0
0
530
def _input(n): return [int(raw_input()) if i in xrange(n)] def LIS(arr): arr = [0] + arr L = [0] + [0] * len(arr) P = [-1] + [0] * len(arr) for i in xrange(1, len(arr)): k = 0 for j in xrange(0, i): if arr[j] < arr[i] and L[j] > L[k]: k = j L[i] ...
s525711572
p02317
u603049633
1496884334
Python
Python3
py
Runtime Error
0
0
274
from bisect import bisect_left import sys n = int(input()) A = [int(i.rstrip("\n")) for i in sys.stdin.readlines()] def LIS(): L = A[:1] for i in A[1:]: if L[-1] < i: L.append(i) else: L[j] = i return len(L) print(LIS())
s953329187
p02317
u855199458
1503220044
Python
Python3
py
Runtime Error
20
7596
240
# -*- coding: utf-8 -*- from bisect import bisect N = int(input()) A = [int(input()) for _ in range(N)] L = [A[0]] for i in range(1, N): if L[-1] < A[i]: L.append(A[i]) else: L[bisect(L, A[i])] = A[i] print(len(L))
s629254417
p02317
u011621222
1530153404
Python
Python3
py
Runtime Error
20
5600
436
n = int(input()) parent = [-1]*n def root(x): if parent[x] < 0: return x parent[x] = y = root(parent[x]) return y def union(x, y): px = root(x) py = root(y) if px == py: return if px > py: px = root(y) py = root(x) parent[x] += parent[y] parent[y] = px return Q = [] for i in range(n): a = int(input...
s183785957
p02317
u766926358
1530154266
Python
Python3
py
Runtime Error
20
5608
631
n = int(input()) parent = [-1]*n def root(x): if parent[x] < 0: return x parent[x] = y = root(parent[x]) return y def union(x, y): px = root(x) py = root(y) if px == py: return if px > py: px = root(y) py = root(x) parent[x] += parent[y] parent[y] = px return Q = [] for i in range(n): a = int(input(...
s805278681
p02317
u603577460
1530624650
Python
Python3
py
Runtime Error
0
0
492
#include <bits/stdc++.h> using namespace std; int T; int DS[1001]; int DP[1001][1001]; int f(int i,int backed){ int &s = DP[i][backed]; if(i==T)return s=0; else if(backed!=T && DS[i]<=DS[backed])return s=f(i+1,backed); else return s=max(1+f(i+1,i),f(i+1,backed)); } int main(){ ios_base::sync_with...
s201328933
p02317
u603577460
1530625584
Python
Python3
py
Runtime Error
0
0
521
#include <bits/stdc++.h> using namespace std; int T; int DS[10001]; int DP[1001][1001]; int f(int i,int backed){ int &s = DP[i][backed]; if(i==T)return s=0; else if(s!=-1)return s; else if(backed!=T && DS[i]<=DS[backed])return s=f(i+1,backed); else return s=max(1+f(i+1,i),f(i+1,backed)); } int ma...
s145733681
p02317
u603577460
1530636977
Python
Python3
py
Runtime Error
0
0
479
#include <bits/stdc++.h> using namespace std; int DP[100001]; int DS[100001]; int T; int LIS(){ int maxan=0; for(int k=0;k<T;k++){ DP[k]=1; for(int i=0;i<k;i++){ if(DS[i]<DS[k])DP[k]=max(DP[k],DP[i]+1); } maxan = max(maxan,DP[k]); } return maxan; } int ...
s314441062
p02318
u609614788
1531371135
Python
Python3
py
Runtime Error
0
0
671
#include <iostream> #include <string> int mini(int x,int y){ if(x<y){ return x; }else{ return y; } } int main() { std::string str1,str2; int A[1001][1001]; int gap; std::cin>>str1; std::cin>>str2; for(int i=0;i<=str1.size();i++){ A[0][i]=i; } for(int i=0;i<=str2.size();i++){ A[i]...
s862426268
p02318
u609614788
1531373595
Python
Python3
py
Runtime Error
0
0
985
#include <iostream> #include <string> int mini(int x,int y){ if(x<y){ return x; }else{ return y; } } int main() { std::string str1,str2; int A[1001][1001]; int gap; std::cin>>str1; std::cin>>str2; for(int i=0;i<str1.size();i++){ A[i][0]=i; } for(int i=0;i<str2.size();i++){ A[0][i...
s900701773
p02318
u609614788
1531373751
Python
Python3
py
Runtime Error
0
0
1082
#include <iostream> #include <string> int mini(int x,int y){ if(x<y){ return x; }else{ return y; } } int main() { std::string str1,str2; int A[1001][1001]; int gap; std::cin>>str1; std::cin>>str2; for(int i=0;i<str1.size();i++){ A[i][0]=i; } for(int i=0;i<str2.size();i++){ A[0][i...
s967566198
p02318
u609614788
1531375146
Python
Python3
py
Runtime Error
0
0
1120
#include <iostream> #include <string> int mini(int x,int y){ if(x<y){ return x; }else{ return y; } } int main() { std::string str1,str2; int A[1001][1001]; int gap; std::cin>>str1; std::cin>>str2; for(int i=0;i<=str1.size();i++){ A[i][0]=i; } for(int i=0;i<=str2.size();i++){ A[0]...
s436071078
p02318
u405027099
1531820476
Python
Python
py
Runtime Error
0
0
503
def levenshtein(X,Y): f=[[0 for i in range(len(Y)+1)]for j in range(len(X)+1)] for i in range(len(X)+1): f[i][0]=i for j in range(1,len(Y)+1): f[0][j]=j for i in range(1,len(X)+1): for j in range(len(Y)+1): if X[i-1]==Y[j-1]: f[i][j]=min(f[i-1][j]+1,f[...
s606988860
p02318
u063056051
1531828281
Python
Python3
py
Runtime Error
0
0
465
list1=list(input()) list2=list(input()) cost=0 list_d=[[0 for i in range(len(list2)+1)] for j in range(list1)+1] for i in range(1,len(list1)+1): list_d[i][0]=i for j in range(1,len(list2)+1): list_d[0][j]=j for i in range(1,len(list1)+1): for j in range(1,len(list2)+1): if list1[i-1]!=list2[j-1]: cost=...
s175532849
p02318
u063056051
1531828331
Python
Python3
py
Runtime Error
0
0
470
list1=list(input()) list2=list(input()) cost=0 list_d=[[0 for i in range(len(list2)+1)] for j in range(len(list1))+1] for i in range(1,len(list1)+1): list_d[i][0]=i for j in range(1,len(list2)+1): list_d[0][j]=j for i in range(1,len(list1)+1): for j in range(1,len(list2)+1): if list1[i-1]!=list2[j-1]: ...
s989739819
p02318
u063056051
1531828636
Python
Python3
py
Runtime Error
0
0
432
list1=list(input()) list2=list(input()) list_d=[[0 for i in range(len(list2)+1)] for j in range(len(list1)+1)] list_d[1][0]=1 list_d[0][1]=1 for i in range(1,len(list1)+1): for j in range(1,len(list2)+1): list_d[i][0]=i list_d[0][j]=j if list1[i-1]!=list2[j-1]: cost=1 else: cost=0 list...
s112977234
p02318
u411881271
1531849394
Python
Python3
py
Runtime Error
0
0
475
n = int(input()) cnt=[0 for i in range(n)] for i in range(n): A = [] A = input() B = [] B = input() DP = [[0 for k in range(len(B)+1)] for j in range(len(A)+1)] for j in range(len(A)+1): DP[j][0]=j for k in range(len(B)+1): DP[0][k]=k for j in range(len(A)): for k in range(len(B)): if A[j]==B[k]:...
s143901091
p02318
u481175672
1531849405
Python
Python3
py
Runtime Error
0
0
505
import numpy as np x=input() y=input() if(x==y): #同じなら0を出力して終了 print(0) exit() list = np.zeros((len(y)+1,len(x)+1)) for i in range(1,len(x)+1): list[0][i] = list[0][i-1]+1 for i in range(1,len(y)+1): list[i][0] = list[i-1][0]+1 for i in range(1,len(y)+1): for j in range(1,len(x)+1): a=list[i-1]...
s741964778
p02318
u481175672
1531849438
Python
Python3
py
Runtime Error
0
0
502
import numpy x=input() y=input() if(x==y): #同じなら0を出力して終了 print(0) exit() list = numpy.zeros((len(y)+1,len(x)+1)) for i in range(1,len(x)+1): list[0][i] = list[0][i-1]+1 for i in range(1,len(y)+1): list[i][0] = list[i-1][0]+1 for i in range(1,len(y)+1): for j in range(1,len(x)+1): a=list[i-1][j-...
s105192508
p02318
u408444038
1531862302
Python
Python3
py
Runtime Error
0
0
519
def L_common(str1,str2): d = [0 for i in range(len(str2)+1)] for n1 in str1: tmp = d[:] for (j,n2) in enumerate(str2): if n1 == n2: d[j+1] = tmp[j]+1 elif d[j+1]<d[j]: d[j+1] = d[j] return d[len(str2)] n = int(input()) stock = [] ...
s859601026
p02318
u909075105
1531885351
Python
Python3
py
Runtime Error
0
0
300
def search(X,Y): n=len(X) m=len(Y) p=[i for i in range(m+1)] for i in range(n): q=list(range(m+1)) q[0] = i+1 for j in range(m): if X[i]==Y[j]: cost=0 else: cost=1 q[j+1]=min(p[j+1]+1,q[j]+1,p[j]+cost) p,q=q,p return pre[m] X=input() Y=input() print(search(X,Y))
s029241933
p02318
u209989098
1532167467
Python
Python3
py
Runtime Error
0
0
439
a = list(input()) b = list(input()) if len(a) == 0 or len(b) == 0: print(max(len(a),len(b))) else: dp = [[None for i in range(len(b)+1)] for j in range(len(a)+1)] for i in range(len(a)+1): dp[i][0] = i for i in range(len(b)+1): dp[0][i] = i for i in range(len(a)+1): for j in range(len(b)+1): aaa = dp[i...
s085193172
p02318
u209989098
1532167589
Python
Python3
py
Runtime Error
0
0
441
a = list(input()) b = list(input()) if len(a) == 0 or len(b) == 0: print(max(len(a),len(b))) else: dp = [[None for i in range(len(b)+1)] for j in range(len(a)+1)] for i in range(len(a)+1): dp[i][0] = i for i in range(len(b)+1): dp[0][i] = i for i in range(1,len(a)+1): for j in range(len(b)+1): aaa = dp...
s752941014
p02318
u886122084
1559462269
Python
Python3
py
Runtime Error
0
0
668
# python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline def leven(s1, s2): n1 = len(s1) n2 = len(s2) dp = [[0]*(n1+1) for _ in range(n2+1)] for i in range(1, n1+1): dp[0][i] = i for i in range(1, n2+1): dp[i][0] = i for j in range(1, ...
s572359005
p02318
u126202702
1447998449
Python
Python
py
Runtime Error
0
0
401
s1 = raw_input() s2 = raw_input() a = [[0 for i in range(len(s1) + 1)]for i in range(len(s2) + 1)] for i in range(len(s1) + 1): a[0][i] = i for i in range(len(s2) + 1): a[i][0] = i for i in range(len(s2)): for j in range(len(s1)): if s1[i] == s2[j]: a[j+1][i+1] = a[j][i] else: ...