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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s706272158 | p02305 | u893844544 | 1523845762 | Python | Python3 | py | Runtime Error | 30 | 5668 | 300 | import math
c1x,c1y,c1r = [int(i) for i in input().split()]
c2x,c2y,c2r = [int(i) for i in input().split()]
d = math.sqrt(pow(c1x-c2x, 2) + pow(c1y-c2y, 2))
if d > c1r + c2r:
print(4)
elif d == c1r + c2r:
print(3)
elif d > s/2:
print(2)
elif d == s/2:
print(1)
else:
print(0)
|
s751945220 | p02305 | u893844544 | 1523857127 | Python | Python3 | py | Runtime Error | 0 | 0 | 424 |
nv,ne = [int(i) for i in input().split()]
g = []
for i in range(nv):
g.append([])
for i in range(ne):
s,t = [int(j) for j in input().split()]
g[s].append(t)
done = []
f = 0
def put_forword(index):
global f
if index in done:
return
done.append(index)
for s in g[index]:
... |
s909243716 | p02305 | u893844544 | 1523857319 | Python | Python3 | py | Runtime Error | 0 | 0 | 422 |
nv,ne = [int(i) for i in input().split()]
g = []
for i in range(nv):
g.append([])
for i in range(ne):
s,t = [int(j) for j in input().split()]
g[s].append(t)
done = []
f = 0
def put_forword(index):
global f
if index in done:
return
done.append(index)
for i in g[index]:
... |
s737092600 | p02305 | u893844544 | 1524435963 | Python | Python3 | py | Runtime Error | 0 | 0 | 462 |
nv,ne = [int(i) for i in input().split()]
g = [[] for i in range(nv)]
for i in range(ne):
s,t = [int(j) for j in input().split()]
g[s].append(t)
visited = [False for i in range(nv)]
f = 0
def pursue_from(index):
global f
if visited[index]:
return
visited[index] = True
for next_i... |
s500849879 | p02308 | u629780968 | 1546439481 | Python | Python3 | py | Runtime Error | 0 | 0 | 836 | import math
def dot(a, b):
return a.real * b.real + a.imag * b.imag
def projection(p0,p1,p2):
a=p1-p0
b=p2-p0
pro = a * dot(a, b) / (abs(a) ** 2)
t=p0+pro
return t
def get_cross_point(p0,p1,p2):
pro=projection(p0,p1,p2)
e =(p1-p0)/abs(p1-p0)
base = math.sqrt(r*r-(abs(pro-p2)**2))
if pro-e*base.re... |
s191020671 | p02308 | u879226672 | 1432488984 | Python | Python | py | Runtime Error | 10 | 4448 | 938 | # coding: utf-8
import math
def solve(a,b,c):
# square equation ax**2 + 2b*x + c == 0
return (-b - math.sqrt(b**2 - a*c)) / a, (-b + math.sqrt(b**2 - a*c)) / a
x0, y0, r = map(float, raw_input().split())
q = int(raw_input())
for i in range(q):
x1, y1, x2, y2 = map(float, raw_input().split())
# line: y... |
s564471406 | p02308 | u879226672 | 1432489112 | Python | Python | py | Runtime Error | 10 | 4452 | 990 | # coding: utf-8
import math
def solve(a,b,c):
# square equation ax**2 + 2b*x + c == 0
return (-b - math.sqrt(b**2 - a*c)) / a, (-b + math.sqrt(b**2 - a*c)) / a
x0, y0, r = map(float, raw_input().split())
q = int(raw_input())
for i in range(q):
x1, y1, x2, y2 = map(float, raw_input().split())
# line: y... |
s194054685 | p02308 | u879226672 | 1432489259 | Python | Python | py | Runtime Error | 10 | 4452 | 970 | import math
def solve(a,b,c):
# square equation ax**2 + 2*b*x + c == 0
return (-b - math.sqrt(b**2 - a*c)) / a, (-b + math.sqrt(b**2 - a*c)) / a
x0, y0, r = map(float, raw_input().split())
q = int(raw_input())
for i in range(q):
x1, y1, x2, y2 = map(float, raw_input().split())
# line: y = mx + n
#... |
s142482820 | p02308 | u879226672 | 1432489936 | Python | Python | py | Runtime Error | 10 | 4460 | 1107 | # coding: utf-8
import math
def solve(a,b,c):
# square equation ax**2 + 2*b*x + c == 0
return (-b - math.sqrt(b**2 - a*c)) / a, (-b + math.sqrt(b**2 - a*c)) / a
x0, y0, r = map(float, raw_input().split())
q = int(raw_input())
for i in range(q):
x1, y1, x2, y2 = map(float, raw_input().split())
# line: ... |
s166098308 | p02308 | u879226672 | 1432490823 | Python | Python | py | Runtime Error | 10 | 4496 | 1394 | # coding: utf-8
import math
def solve(a,b,c):
# square equation ax**2 + 2*b*x + c == 0
return (-b - math.sqrt(b**2 - a*c)) / a, (-b + math.sqrt(b**2 - a*c)) / a
x0, y0, r = map(float, raw_input().split())
q = int(raw_input())
for i in range(q):
x1, y1, x2, y2 = map(float, raw_input().split())
# line: ... |
s640920885 | p02308 | u879226672 | 1432490879 | Python | Python | py | Runtime Error | 10 | 4496 | 1402 | # coding: utf-8
import math
def solve(a,b,c):
# square equation ax**2 + 2*b*x + c == 0
return (-b - math.sqrt(b**2 - a*c)) / a, (-b + math.sqrt(b**2 - a*c)) / a
x0, y0, r = map(float, raw_input().split())
q = int(raw_input())
for i in range(q):
x1, y1, x2, y2 = map(float, raw_input().split())
# line: ... |
s812550482 | p02308 | u879226672 | 1432490971 | Python | Python | py | Runtime Error | 20 | 4500 | 1394 | # coding: utf-8
import math
def solve(a,b,c):
# square equation ax**2 + 2*b*x + c == 0
return (-b - math.sqrt(b**2 - a*c)) / a, (-b + math.sqrt(b**2 - a*c)) / a
x0, y0, r = map(float, raw_input().split())
q = int(raw_input())
for i in range(q):
x1, y1, x2, y2 = map(float, raw_input().split())
# line: ... |
s095278172 | p02308 | u879226672 | 1432491082 | Python | Python | py | Runtime Error | 10 | 4496 | 1357 | # coding: utf-8
import math
def solve(a,b,c):
# square equation ax**2 + 2*b*x + c == 0
return (-b - math.sqrt(b**2 - a*c)) / a, (-b + math.sqrt(b**2 - a*c)) / a
x0, y0, r = map(float, raw_input().split())
q = int(raw_input())
for i in range(q):
x1, y1, x2, y2 = map(float, raw_input().split())
# line: ... |
s974707156 | p02308 | u879226672 | 1432491158 | Python | Python | py | Runtime Error | 20 | 4500 | 1370 | # coding: utf-8
import math
def solve(a,b,c):
# square equation ax**2 + 2*b*x + c == 0
return (-b - math.sqrt(b**2 - a*c)) / a, (-b + math.sqrt(b**2 - a*c)) / a
x0, y0, r = map(float, raw_input().split())
q = int(raw_input())
for i in range(q):
x1, y1, x2, y2 = map(float, raw_input().split())
# line: ... |
s774543166 | p02308 | u879226672 | 1432524449 | Python | Python | py | Runtime Error | 10 | 4500 | 1370 | # coding: utf-8
import math
def solve(a,b,c):
# square equation ax**2 + 2*b*x + c == 0
return (-b - math.sqrt(b**2 - a*c)) / a, (-b + math.sqrt(b**2 - a*c)) / a
x0, y0, r = map(float, raw_input().split())
q = int(raw_input())
for i in range(q):
x1, y1, x2, y2 = map(float, raw_input().split())
# line: ... |
s385698365 | p02308 | u662418022 | 1520747252 | Python | Python3 | py | Runtime Error | 0 | 0 | 2701 | # -*- coding: utf-8 -*-
import collections
import math
class Vector2(collections.namedtuple("Vector2", ["x", "y"])):
def __add__(self, other):
return Vector2(self.x + other.x, self.y + other.y)
def __sub__(self, other):
return Vector2(self.x - other.x, self.y - other.y)
def __mul__(se... |
s099690808 | p02314 | u467175809 | 1531290907 | Python | Python | py | Runtime Error | 0 | 0 | 63 | n, m = map(int, raw_input())
c = map(int, raw_input())
print 0
|
s761584325 | p02314 | u467175809 | 1531290928 | Python | Python | py | Runtime Error | 0 | 0 | 79 | n, m = map(int, raw_input().split())
c = map(int, raw_input()_split())
print 0
|
s535582547 | p02314 | u209989098 | 1531369723 | Python | Python3 | py | Runtime Error | 0 | 0 | 176 | a,b = map(int,input().split())
c = list(map(int,input().split()))
c.reversed()
su = 0
for i in range(b):
if a >= c[i]:
a %= c[i]
su += 1
print(su)
|
s836509693 | p02314 | u209989098 | 1531371635 | Python | Python3 | py | Runtime Error | 0 | 0 | 260 | a,b = map(int,input().split())
c = list(map(int,input(),split()))
dp = [float("inf") for i in range(n+2)]
for i in range(n+1):
for j in c:
if i + j <= n:
dp[i+j] = min(dp[i+j],dp[i] + 1)
print(dp[a])
|
s206137037 | p02314 | u209989098 | 1531371656 | Python | Python3 | py | Runtime Error | 0 | 0 | 260 | a,b = map(int,input().split())
c = list(map(int,input().split()))
dp = [float("inf") for i in range(n+2)]
for i in range(n+1):
for j in c:
if i + j <= n:
dp[i+j] = min(dp[i+j],dp[i] + 1)
print(dp[a])
|
s131247020 | p02314 | u209989098 | 1531371665 | Python | Python3 | py | Runtime Error | 0 | 0 | 260 | a,b = map(int,input().split())
c = list(map(int,input().split()))
dp = [float("inf") for i in range(a+2)]
for i in range(n+1):
for j in c:
if i + j <= n:
dp[i+j] = min(dp[i+j],dp[i] + 1)
print(dp[a])
|
s911241948 | p02314 | u692132831 | 1545204785 | Python | Python3 | py | Runtime Error | 0 | 0 | 450 | def coin(a, b, c):
global count
global m
if a % c[0] == 0:
count = min(count, b + a // c[0])
return count
elif b + a // c[0] >= count:
return n
elif c[0] < n:
return min(cs(a - c[0], b + 1, c), cs(a, b, c[1:]))
else:
return coin(a, b, c[1:])
n,... |
s957906106 | p02314 | u692132831 | 1545204830 | Python | Python3 | py | Runtime Error | 0 | 0 | 452 | def coin(a, b, c):
global count
global m
if a % c[0] == 0:
count = min(count, b + a // c[0])
return count
elif b + a // c[0] >= count:
return n
elif c[0] < n:
return min(coin(a - c[0], b + 1, c), cs(a, b, c[1:]))
else:
return coin(a, b, c[1:])
... |
s661106963 | p02314 | u692132831 | 1545205169 | Python | Python3 | py | Runtime Error | 0 | 0 | 458 | def coin(a, b, c):
global count
global m
if a % c[0] == 0:
count = min(count, b + a // c[0])
return count
elif b + a // c[0] >= count:
return n
elif c[0] < n:
return min(coin(a - c[0], b + 1, c), coin(a, b, c[1:]))
else:
return coin(a, b, c[1:])
... |
s114052425 | p02314 | u210992699 | 1556851973 | Python | Python3 | py | Runtime Error | 20 | 5720 | 198 | n, m =map(int,input().split())
c = list(map(int,input().split()))
INF = 10**10
dp = [INF]*50000
dp[0] = 0
for i in range (n+1):
for j in c:
dp[i+j] = min(dp[i+j],dp[i]+1)
print(dp[n])
|
s988734870 | p02314 | u210992699 | 1556852137 | Python | Python3 | py | Runtime Error | 20 | 5720 | 198 | n, m =map(int,input().split())
c = list(map(int,input().split()))
INF = 10**10
dp = [INF]*50000
dp[0] = 0
for i in range (n+1):
for j in c:
dp[i+j] = min(dp[i+j],dp[i]+1)
print(dp[n])
|
s911098472 | p02314 | u210992699 | 1556852161 | Python | Python3 | py | Runtime Error | 20 | 5600 | 196 | n, m =map(int,input().split())
c = list(map(int,input().split()))
INF = 10**10
dp = [INF]*500
dp[0] = 0
for i in range (n+1):
for j in c:
dp[i+j] = min(dp[i+j],dp[i]+1)
print(dp[n])
|
s189355921 | p02314 | u210992699 | 1556852211 | Python | Python3 | py | Runtime Error | 0 | 0 | 203 | n, m =map(int,input().split())
c = list(map(int,input().split()))
INF = 10**10
dp = [INF]*(n+max(c))
dp[0] = 0
for i in range (n+1):
for j in c:
dp[i+j] = min(dp[i+j],dp[i]+1)
print(dp[n])
|
s449925378 | p02314 | u210992699 | 1556852267 | Python | Python3 | py | Runtime Error | 20 | 5640 | 199 | n, m =map(int,input().split())
c = list(map(int,input().split()))
INF = 10**10
dp = [INF]*(n**2)
dp[0] = 0
for i in range (n+1):
for j in c:
dp[i+j] = min(dp[i+j],dp[i]+1)
print(dp[n])
|
s405954824 | p02314 | u106851363 | 1447905307 | Python | Python3 | py | Runtime Error | 0 | 0 | 320 | C = int(input().split()[0])
V = [int(i) for i in input().split()]
N = len(V)
M = [None for _ in range(C+1)]
for i in range(C+1):
M[i] = [0 for _ in range(N)]
for j in range(n):
M[0][j] = 0
for i in range(1, C+1):
for j in range(n):
M[i][j] = min([ (M[i-x*V[j]][j-1] + x) for x in range(C//V[j]) ])
print(M[-1][-1]) |
s587217561 | p02314 | u106851363 | 1447905671 | Python | Python3 | py | Runtime Error | 0 | 0 | 320 | C = int(input().split()[0])
V = [int(i) for i in input().split()]
N = len(V)
M = [None for _ in range(C+1)]
for i in range(C+1):
M[i] = [0 for _ in range(N)]
for j in range(n):
M[0][j] = 0
for i in range(1, C+1):
for j in range(N):
M[i][j] = min([ (M[i-x*V[j]][j-1] + x) for x in range(C//V[j]) ])
print(M[-1][-1]) |
s418213276 | p02314 | u126202702 | 1448003631 | Python | Python | py | Runtime Error | 0 | 0 | 272 | n, m = map(int, raw_input().split())
c = map(int, raw_input().split())
t = [float('inf') for i in range(n+1)]
t[0] = 0
for i in range(n+1):
if c[i] > n:
break
else:
for j in range(c[i], n+1):
t[j] = min([t[j], t[j-c[i]]+1])
print t[n] |
s001192878 | p02314 | u126202702 | 1448003797 | Python | Python | py | Runtime Error | 0 | 0 | 270 | n, m = map(int, raw_input().split())
c = map(int, raw_input().split())
t = [float('inf') for i in range(n+1)]
t[0] = 0
for i in range(n):
if c[i] > n:
break
else:
for j in range(c[i], n+1):
t[j] = min([t[j], t[j-c[i]]+1])
print t[n] |
s425741375 | p02314 | u397460030 | 1456578555 | Python | Python3 | py | Runtime Error | 20 | 7656 | 276 | from itertools import product
value, variety = map(int, input().split())
coins = list(map(int, input().split()))
dp = [float("inf") for _ in range(value + 1)]
dp[0] = 0
for (c,j) in product(coins,list(range(value + 1))):
dp[j] = min(dp[j], dp[j - c] + 1)
print(dp[value]) |
s452069029 | p02314 | u397460030 | 1456578592 | Python | Python3 | py | Runtime Error | 20 | 7672 | 276 | from itertools import product
value, variety = map(int, input().split())
coins = list(map(int, input().split()))
dp = [float("inf") for _ in range(value + 1)]
dp[0] = 0
for (c,j) in product(coins,list(range(value + 1))):
dp[j] = min(dp[j], dp[j - c] + 1)
print(dp[value]) |
s579875572 | p02314 | u260980560 | 1465192176 | Python | Python | py | Runtime Error | 10 | 6472 | 352 | n, m = map(int, raw_input().split())
c = map(int, raw_input().split())
memo = [-1] * (n+1)
def dfs(rest):
if memo[rest] != -1:
return memo[rest]
if rest == 0:
return 0
res = n+1
for i in xrange(m):
if c[i] <= rest:
res = min(res, 1 + dfs(rest - c[i]))
memo[rest] =... |
s623528318 | p02314 | u408260374 | 1474512991 | Python | Python3 | py | Runtime Error | 50 | 8452 | 310 | import functools
@functools.lru_cache(maxsize=None)
def rec(c):
if c <= 0:
return 0 if c == 0 else INF
ret = INF
for coin in coins:
ret = min(ret, rec(c-coin) + 1)
return ret
INF = 10**6
N, M = map(int, input().split())
coins = [int(x) for x in input().split()]
print(rec(N)) |
s557705204 | p02314 | u408260374 | 1474513223 | Python | Python3 | py | Runtime Error | 0 | 0 | 353 | import functools, sys
@functools.lru_cache(maxsize=None)
def rec(c):
if c == 0:
return 0
ret = INF
for coin in coins:
if c - coin >= 0:
ret = min(ret, rec(c-coin) + 1)
return ret
INF = 10**6
N, M = map(int, input().split())
sys.setrecursionlimit(N+1)
coins = [int(x) for x ... |
s239794768 | p02314 | u408260374 | 1474513291 | Python | Python3 | py | Runtime Error | 80 | 44420 | 353 | import functools, sys
@functools.lru_cache(maxsize=None)
def rec(c):
if c == 0:
return 0
ret = INF
for coin in coins:
if c - coin >= 0:
ret = min(ret, rec(c-coin) + 1)
return ret
INF = 10**6
N, M = map(int, input().split())
coins = [int(x) for x in input().split()]
sys.set... |
s150198023 | p02314 | u508732591 | 1482039337 | Python | Python3 | py | Runtime Error | 0 | 0 | 308 | n,m = map(int,input().split())
c = list(map(int,input().split()))
minimum = [50000] * (n+1)
minimum[0] = 0
for i in range(1,n+1):
if c[j] <= 2:
continue
for j in range(m):
if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]:
minimum[i] = minimum[i-c[j]]+1
print(minimum[n]) |
s631788682 | p02314 | u252368621 | 1482213143 | Python | Python3 | py | Runtime Error | 30 | 7744 | 520 | def dfs(index,n,m,c,dp):
if dp[index][m] != 30:
return dp[index][m]
if index==n:
return n+1
if m==c[index]:
return 1
if m<c[index]:
return dfs(index+1,n,m,c,dp)
ret=min(dfs(index+1,n,m,c,dp),
dfs(index+1,n,m-c[index],c,dp)+1,
dfs(index,n,m-... |
s517835086 | p02314 | u865312527 | 1485109144 | Python | Python | py | Runtime Error | 0 | 0 | 257 | n, m = map(int, raw_input().split())
c = map(int, raw_input().split())
INF = 1000000000
t = [INF] * n
t[0] = 0
for i in range(m):
# print(c[i])
for j in range(c[i], n):
t[j] = min([t[j], t[j - c[i]] + 1])
# print(t)
print(t[n - 1])
~ |
s149838726 | p02314 | u837811962 | 1497090571 | Python | Python3 | py | Runtime Error | 0 | 0 | 376 | currency = list(map(int,input().split()))
gra = [[0 for i in range(n+1)] for i in range(m)]
for i in range(m):
for j in range(1,n+1):
if i == 0:
gra[i][j] = j
else:
if j>=currency[i]:
gra[i][j] = min(gra[i-1][j],gra[i][j-currency[i]]+1)
else:
... |
s172576577 | p02314 | u837811962 | 1497090597 | Python | Python3 | py | Runtime Error | 0 | 0 | 376 | currency = list(map(int,input().split()))
gra = [[0 for i in range(n+1)] for i in range(m)]
for i in range(m):
for j in range(1,n+1):
if i == 0:
gra[i][j] = j
else:
if j>=currency[i]:
gra[i][j] = min(gra[i-1][j],gra[i][j-currency[i]]+1)
else:
... |
s046861212 | p02314 | u837811962 | 1497152582 | Python | Python3 | py | Runtime Error | 0 | 0 | 376 | currency = list(map(int,input().split()))
gra = [[0 for i in range(n+1)] for i in range(m)]
for i in range(m):
for j in range(1,n+1):
if i == 0:
gra[i][j] = j
else:
if j>=currency[i]:
gra[i][j] = min(gra[i-1][j],gra[i][j-currency[i]]+1)
else:
... |
s916465570 | p02314 | u837811962 | 1497152620 | Python | Python3 | py | Runtime Error | 0 | 0 | 376 | currency = list(map(int,input().split()))
gra = [[0 for i in range(n+1)] for i in range(m)]
for i in range(m):
for j in range(1,n+1):
if i == 0:
gra[i][j] = j
else:
if j>=currency[i]:
gra[i][j] = min(gra[i-1][j],gra[i][j-currency[i]]+1)
else:
... |
s154448646 | p02314 | u837811962 | 1497154118 | Python | Python3 | py | Runtime Error | 0 | 0 | 376 | currency = list(map(int,input().split()))
gra = [[0 for i in range(n+1)] for i in range(m)]
for i in range(m):
for j in range(1,n+1):
if i == 0:
gra[i][j] = j
else:
if j>=currency[i]:
gra[i][j] = min(gra[i-1][j],gra[i][j-currency[i]]+1)
else:
... |
s483230698 | p02314 | u216229195 | 1497246388 | Python | Python3 | py | Runtime Error | 4400 | 42556 | 855 | n, m = input().split()
n = int(n)
m = int(m)
c = []
c = input().split()
for i in range(0,m):
c[i] = int(c[i])
d = c[:]
c.reverse()
y = n
min = 0
while 1:
if len(d) == 0:
break
if y < max(d):
d.pop()
else:
min += int(y/max(d))
y = y % max(d)
d.pop()
#print(min)
memo = {}
#min = 100000000
depth = 0
de... |
s904078270 | p02314 | u216229195 | 1497246433 | Python | Python3 | py | Runtime Error | 4310 | 42768 | 862 | #coding: cp932
n, m = input().split()
n = int(n)
m = int(m)
c = []
c = input().split()
for i in range(0,m):
c[i] = int(c[i])
d = c[:]
c.reverse()
y = n
min = 0
while 1:
if len(d) == 0:
break
if y < max(d):
d.pop()
else:
min += int(y/max(d))
y = y % max(d)
d.pop()
#print(min)
memo = {}
#min = 1000000... |
s395742337 | p02314 | u216229195 | 1497249172 | Python | Python3 | py | Runtime Error | 0 | 0 | 911 | #coding: cp932
n, m = input().split()
n = int(n)
m = int(m)
c = []
c = input().split()
for i in range(0,m):
c[i] = int(c[i])
d = c[:]
c.reverse()
y = n
min = 0
while 1:
if len(d) == 0:
break
if y < max(d):
d.pop()
else:
min += int(y/max(d))
y = y % max(d)
d.pop()
#print(min)
memo = []
for i in range(... |
s985439435 | p02314 | u216229195 | 1497249198 | Python | Python3 | py | Runtime Error | 0 | 0 | 911 | #coding: cp932
n, m = input().split()
n = int(n)
m = int(m)
c = []
c = input().split()
for i in range(0,m):
c[i] = int(c[i])
d = c[:]
c.reverse()
y = n
min = 0
while 1:
if len(d) == 0:
break
if y < max(d):
d.pop()
else:
min += int(y/max(d))
y = y % max(d)
d.pop()
#print(min)
memo = []
for i in range(... |
s868430048 | p02314 | u216229195 | 1497249226 | Python | Python3 | py | Runtime Error | 30 | 7740 | 787 | n, m = input().split()
n = int(n)
m = int(m)
c = []
c = input().split()
for i in range(0,m):
c[i] = int(c[i])
d = c[:]
c.reverse()
y = n
min = 0
while 1:
if len(d) == 0:
break
if y < max(d):
d.pop()
else:
min += int(y/max(d))
y = y % max(d)
d.pop()
#print(min)
memo = []
for i in range(0,min+1):
memo.... |
s632628037 | p02314 | u216229195 | 1497249252 | Python | Python3 | py | Runtime Error | 30 | 7728 | 787 | n, m = input().split()
n = int(n)
m = int(m)
c = []
c = input().split()
for i in range(0,m):
c[i] = int(c[i])
d = c[:]
c.reverse()
y = n
min = 0
while 1:
if len(d) == 0:
break
if y < max(d):
d.pop()
else:
min += int(y/max(d))
y = y % max(d)
d.pop()
#print(min)
memo = []
for i in range(0,min+1):
memo.... |
s260688170 | p02314 | u705768168 | 1513323688 | Python | Python | py | Runtime Error | 10 | 4688 | 426 | def calc_t(i,j):
global t,c
if i<0 or j<0:
return n+2
#print("get t["+str(i)+","+str(j)+"]")
if t[i][j]==n+1:
t[i][j]=min(calc_t(i-1,j),calc_t(i,j-c[i])+1)
return t[i][j]
ri=raw_input().split(" ")
n=int(ri[0])
m=int(ri[1])
ri=raw_input().split(" ")
c=[0]*m
t=[0]*m
for i in range(m):... |
s277411856 | p02314 | u717102979 | 1515331728 | Python | Python3 | py | Runtime Error | 40 | 6800 | 801 | #! /usr/bin/env python3
'''
Author: krishna
Created: Sun Jan 7 12:52:35 2018 IST
File Name: minCoinChange.py
USAGE:
minCoinChange.py
Description:
'''
import sys, traceback, math
def solve(count, sol):
'''
Solve the problem ;)
'''
if not (count in sol):
s = math.inf
for i ... |
s244400190 | p02314 | u869924057 | 1518602695 | Python | Python3 | py | Runtime Error | 670 | 5620 | 955 | nm = input().split(' ')
n = int(nm[0])
m = int(nm[1])
c = list(map(int, input().split(' ')))
dp = {}
# cの要素のうちp番目以降を組み合わせてtを作れるか?作れるならその数を返す
def solve(p, t, num):
# 使う/使わないの枝をたどって0になったらOK
if (t == 0):
return (True, num)
# p, tが不正な値になればその枝は終了
if (p == m or t < 0):
return (False, num)
# p番目を使ったらtを引いて... |
s892824438 | p02314 | u869924057 | 1518603071 | Python | Python3 | py | Runtime Error | 40 | 8092 | 1087 | import sys
sys.setrecursionlimit(50001)
nm = input().split(' ')
n = int(nm[0])
m = int(nm[1])
c = list(map(int, input().split(' ')))
dp = {}
# cの要素のうちp番目以降を組み合わせてtを作れるか?作れるならその数を返す
def solve(p, t, num):
if ((p, t, num) in dp):
return dp[(p, t, num)]
# 使う/使わないの枝をたどって0になったらOK
if (t == 0):
return (True, ... |
s433171830 | p02314 | u869924057 | 1518692137 | Python | Python3 | py | Runtime Error | 0 | 0 | 1191 | nm = input().split(' ')
n = int(nm[0])
m = int(nm[1])
c = list(map(int, input().split(' ')))
dp = {}
# cの要素のうちp番目以降を組み合わせてtを作れるか?作れるならその数を返す
def solve(p, t):
if ((p, t) in dp):
return dp[(p, t)]
# 使う/使わないの枝をたどって0になったらOK
if (p == m):
return 0 if t == 0 else 50001
# p番目を1枚だけ使う
# p番目を使わずに次へ, 使ったらtから引... |
s300603222 | p02314 | u869924057 | 1518692163 | Python | Python3 | py | Runtime Error | 0 | 0 | 1232 | import sys
sys.setrecursionlimit(65532)
nm = input().split(' ')
n = int(nm[0])
m = int(nm[1])
c = list(map(int, input().split(' ')))
dp = {}
# cの要素のうちp番目以降を組み合わせてtを作れるか?作れるならその数を返す
def solve(p, t):
if ((p, t) in dp):
return dp[(p, t)]
# 使う/使わないの枝をたどって0になったらOK
if (p == m):
return 0 if t == 0 else 50001... |
s575001044 | p02314 | u609484772 | 1525590790 | Python | Python3 | py | Runtime Error | 30 | 5656 | 468 | import math
n, m = map(int,input().split(' '))
d = list(map(int,input().split(' ')))
d.sort()
inf = n
dp = [ [ inf for i in range(m+1)] for j in range(n+1) ]
# dp
for j in range(m+1):
dp[0][j]=0
for j in range(m-1,-1,-1):
for i in range(n+1):
#for k in range(math.floor(i/d[j])+1):
k=1
... |
s000023174 | p02314 | u255317651 | 1527322743 | Python | Python3 | py | Runtime Error | 750 | 7236 | 578 | # -*- coding: utf-8 -*-
"""
Created on Sat May 26 12:16:54 2018
DPL-1A Rec Call Revised
@author: maezawa
"""
n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
c.sort(reverse=True)
dp = [float('inf') for _ in range(n+1)]
dp[0] = 0
#print(n,m)
#print(c)
#print(*dp, sep='\n')
def min_number(nn):... |
s803724397 | p02314 | u255317651 | 1527323267 | Python | Python3 | py | Runtime Error | 770 | 7232 | 578 | # -*- coding: utf-8 -*-
"""
Created on Sat May 26 12:16:54 2018
DPL-1A Rec Call Revised
@author: maezawa
"""
n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
c.sort(reverse=True)
dp = [float('inf') for _ in range(n+1)]
dp[0] = 0
#print(n,m)
#print(c)
#print(*dp, sep='\n')
def min_number(nn):... |
s634815241 | p02314 | u467175809 | 1528470053 | Python | Python3 | py | Runtime Error | 20 | 5640 | 351 | #!/usr/bin/env python
n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
DP = {}
def func(num, yen):
if num < 0 or yen < 0:
return 10 ** 18
if num == 0 and yen == 0:
return 0
if not (num, yen) in DP:
DP[(num, yen)] = min(func(num - 1, yen), func(num, yen - c[num]) + 1)
return DP[(num,... |
s006179358 | p02315 | u636240697 | 1531692437 | Python | Python3 | py | Runtime Error | 0 | 0 | 1091 | import numpy as np
n, W = map(int, input().split())
value = np.empty(110)
weight = np.empty(110)
dp = np.empty(110,10010)
for el in range(n):
value[el], weight[el] = map(int, input().split())
for w in range(W):
dp[0][w] = 0
for i in range(n):
for w in range(W + 1):
if w >= weight[i]:
... |
s540744394 | p02315 | u636240697 | 1531693197 | Python | Python3 | py | Runtime Error | 0 | 0 | 1141 | import numpy as np
n, W = map(int, input().split())
value = np.empty(110, dtype = 'int8')
weight = np.empty(110, dtype = 'int8')
dp = np.empty((110,10010), dtype = 'int8')
for el in range(n):
value[el], weight[el] = map(int, input().split())
for w in range(W):
dp[0][w] = 0
for i in range(n):
for w in r... |
s988322270 | p02315 | u209989098 | 1531808650 | Python | Python3 | py | Runtime Error | 0 | 0 | 222 | N,W = map(int, input().split())
dp = [0]*(W+1)
for i in range(1,N+1):
v,w = map(int,input().split())
for j in range(w-1,, W, -1):
print(j)
x = v+dp[j-w]
if x > dp[j]: dp[j] = x
print(dp[W])
|
s953713485 | p02315 | u209989098 | 1531808659 | Python | Python3 | py | Runtime Error | 0 | 0 | 221 | N,W = map(int, input().split())
dp = [0]*(W+1)
for i in range(1,N+1):
v,w = map(int,input().split())
for j in range(w-1, W, -1):
print(j)
x = v+dp[j-w]
if x > dp[j]: dp[j] = x
print(dp[W])
|
s223341737 | p02315 | u209989098 | 1531809233 | Python | Python3 | py | Runtime Error | 0 | 0 | 209 | N , W = map(int,input())
dp[W+1] = [0]
for i in range(N):
n , m = map(input())
for j in range(W,m-1,-1):
x = n + dp[j-m]
if x > dp[j]:
dp[j] = x:
print(dp[W])
|
s928847627 | p02315 | u209989098 | 1531809257 | Python | Python3 | py | Runtime Error | 0 | 0 | 229 | N , W = map(int,input().split())
dp[W+1] = [0]
for i in range(N):
n , m = map(int,input().split())
for j in range(W,m-1,-1):
x = n + dp[j-m]
if x > dp[j]:
dp[j] = x:
print(dp[W])
|
s668893879 | p02315 | u209989098 | 1531809272 | Python | Python3 | py | Runtime Error | 0 | 0 | 230 | N , W = map(int,input().split())
dp[W+1] = [0]
for i in range(N):
n , m = map(int,input().split())
for j in range(W,m-1,-1):
x = n + dp[j-m]
if x >= dp[j]:
dp[j] = x:
print(dp[W])
|
s028594868 | p02315 | u209989098 | 1531809278 | Python | Python3 | py | Runtime Error | 0 | 0 | 229 | N , W = map(int,input().split())
dp[W+1] = [0]
for i in range(N):
n , m = map(int,input().split())
for j in range(W,m-1,-1):
x = n + dp[j-m]
if x >= dp[j]:
dp[j] = x
print(dp[W])
|
s993447268 | p02315 | u209989098 | 1531809301 | Python | Python3 | py | Runtime Error | 0 | 0 | 232 | N , W = map(int,input().split())
dp[] = [0]*(W+1)
for i in range(N):
n , m = map(int,input().split())
for j in range(W,m-1,-1):
x = n + dp[j-m]
if x >= dp[j]:
dp[j] = x
print(dp[W])
|
s532614946 | p02315 | u704330856 | 1540731699 | Python | Python3 | py | Runtime Error | 470 | 24784 | 490 | N, W = (int(i) for i in input().split())
bagage = [[int(i) for i in input().split()] for _ in range(N)]
weight = []
value = []
for b in bagage:
value.append(b[0])
weight.append(b[1])
dp = [[0]*10010 for i in range(100)]
for j in range(W):
dp[N][j] = 0
for i in range(N-1, -1, -1):
for j in range(0, W+... |
s741716878 | p02315 | u025180675 | 1540875427 | Python | Python3 | py | Runtime Error | 0 | 0 | 513 | def ramp(t):
if t >= 0:
return t
else:
return 0
def heav(t):
if t >= 0:
return(1)
else:
return(0)
N,W = map(int,input().strip().split(" "))
lst = []
for i in range(N):
l = list(map(int,input().strip().split(" ")))
lst.append(l)
table = [[0 for c in range(W+1)] fo... |
s878270134 | p02315 | u025180675 | 1540875671 | Python | Python3 | py | Runtime Error | 0 | 0 | 590 | #引数が非負ならそのまま、負なら0を返す
def ramp(t):
if t >= 0:
return t
else:
return 0
def heav(t):
if t >= 0:
return(1)
else:
return(0)
N,W = map(int,input().strip().split(" "))
lst = []
for i in range(N):
l = list(map(int,input().strip().split(" "))) #[v,w]の順で格納
lst.append(l)
tab... |
s488881307 | p02315 | u692132831 | 1545206537 | Python | Python3 | py | Runtime Error | 0 | 0 | 552 | def weight(n, p, c):
global count
global m
if n % c[0] == 0:
count = min(count, p + n // c[0])
return count
elif p + n // c[0] >= count:
return n
elif c[0] < n:
return min(weight(n - c[0], p + 1, c), weight(n, p, c[1:]))
else:
return weight(n, p, c[1:... |
s705597338 | p02315 | u692132831 | 1545206557 | Python | Python3 | py | Runtime Error | 0 | 0 | 552 | def weight(n, p, c):
global count
global m
if n % c[0] == 0:
count = min(count, p + n // c[0])
return count
elif p + n // c[0] >= count:
return n
elif c[0] < n:
return min(weight(n - c[0], p + 1, c), weight(n, p, c[1:]))
else:
return weight(n, p, c[1:... |
s126277137 | p02315 | u692132831 | 1545207545 | Python | Python3 | py | Runtime Error | 0 | 0 | 721 | def weight(n, p, c):
global count
global m
if n % c[0] == 0:
count = min(count, p + n // c[0])
return count
elif p + n // c[0] >= count:
return n
elif c[0] < n:
return min(weight(n - c[0], p + 1, c), weight(n, p, c[1:]))
else:
return weight(n, p, c[1:... |
s408928489 | p02315 | u692132831 | 1545207616 | Python | Python3 | py | Runtime Error | 0 | 0 | 610 | '''
def weight(n, p, c):
global count
global m
if n % c[0] == 0:
count = min(count, p + n // c[0])
return count
elif p + n // c[0] >= count:
return n
elif c[0] < n:
return min(weight(n - c[0], p + 1, c), weight(n, p, c[1:]))
else:
return weight(n, p, ... |
s539630380 | p02315 | u692132831 | 1545207642 | Python | Python3 | py | Runtime Error | 0 | 0 | 612 | '''
def weight(n, p, c):
global count
global m
if n % c[0] == 0:
count = min(count, p + n // c[0])
return count
elif p + n // c[0] >= count:
return n
elif c[0] < n:
return min(weight(n - c[0], p + 1, c), weight(n, p, c[1:]))
else:
return weight(n, p, ... |
s998849989 | p02315 | u692132831 | 1545207653 | Python | Python3 | py | Runtime Error | 0 | 0 | 613 | '''
def weight(n, p, c):
global count
global m
if n % c[0] == 0:
count = min(count, p + n // c[0])
return count
elif p + n // c[0] >= count:
return n
elif c[0] < n:
return min(weight(n - c[0], p + 1, c), weight(n, p, c[1:]))
else:
return weight(n, p, ... |
s795354444 | p02315 | u692132831 | 1545207664 | Python | Python3 | py | Runtime Error | 0 | 0 | 610 | '''
def weight(n, p, c):
global count
global m
if n % c[0] == 0:
count = min(count, p + n // c[0])
return count
elif p + n // c[0] >= count:
return n
elif c[0] < n:
return min(weight(n - c[0], p + 1, c), weight(n, p, c[1:]))
else:
return weight(n, p, ... |
s996257486 | p02315 | u692132831 | 1545207699 | Python | Python3 | py | Runtime Error | 0 | 0 | 610 | '''
def weight(n, p, c):
global count
global m
if n % c[0] == 0:
count = min(count, p + n // c[0])
return count
elif p + n // c[0] >= count:
return n
elif c[0] < n:
return min(weight(n - c[0], p + 1, c), weight(n, p, c[1:]))
else:
return weight(n, p, ... |
s180083223 | p02315 | u692132831 | 1545208292 | Python | Python3 | py | Runtime Error | 0 | 0 | 248 | from sys import *
def ans()
W = int(input().split()[1])
C = [0] *-~ W
for e in stdin:
v,w=map(int,e.split())
for i in range(W, w-1, -1):
t = v + C[i - w]
if t > C[i]:
C[i] = t
print(C[W])
ans()
|
s953895114 | p02315 | u114709303 | 1551412453 | Python | Python3 | py | Runtime Error | 0 | 0 | 477 | n, w = map(int, input().split())
values = [0]
weights = [0]
for i in range(n):
value, weight = map(int, input().split())
values.append(value)
weights.append(weight)
dp = [[0 for i in range(w + 1)] for j in range(len(values) + 1)]
for i in range(len(values)):
for j in range(w + 1):
if weights[... |
s277858937 | p02315 | u114709303 | 1551422504 | Python | Python3 | py | Runtime Error | 0 | 0 | 477 | n, w = map(int, input().split())
values = [0]
weights = [0]
for i in range(n):
value, weight = map(int, input().split())
values.append(value)
weights.append(weight)
dp = [[0 for i in range(w + 1)] for j in range(len(values) + 1)]
for i in range(len(values)):
for j in range(w + 1):
if weights[... |
s549041449 | p02315 | u667315691 | 1556299615 | Python | Python3 | py | Runtime Error | 20 | 5708 | 528 | N,W=(int(x) for x in input().split())
t=0
weight=[0]*N
value=[0]*N
while t<N:
v,w=(int(x) for x in input().split())
value[t]=v
weight[t]=w
t=t+1
def kotae(N,W):
dp=[[0 for i in range(110)] for j in range(110)]
i=0
while i<N:
wei=0
while wei<W+1:
if wei>=weight[i]:... |
s526113318 | p02315 | u667315691 | 1556299702 | Python | Python3 | py | Runtime Error | 20 | 5708 | 528 | N,W=(int(x) for x in input().split())
t=0
weight=[0]*N
value=[0]*N
while t<N:
v,w=(int(x) for x in input().split())
value[t]=v
weight[t]=w
t=t+1
def kotae(N,W):
dp=[[0 for i in range(110)] for j in range(110)]
i=0
while i<N:
wei=0
while wei<W+1:
if wei>=weight[i]:... |
s349014867 | p02315 | u399781630 | 1556404562 | Python | Python3 | py | Runtime Error | 0 | 0 | 602 |
def dp(i, j):
if dp_list[i][j] != -1:
return dp_list[i][j]
if i == len(lists):
return 0
if j < lists[i][1]:
dp_list[i][j] = dp(i + 1, j)
return dp_list[i][j]
else:
dp_list[i][j] = max(dp(i + 1, j), dp(i + 1, j - lists[i][1]) + lists[i][0])
return dp_lis... |
s721124223 | p02315 | u182167513 | 1556702176 | Python | Python3 | py | Runtime Error | 0 | 0 | 833 | #Nはアイテム数、Wはナップサックサイズ
N,W = map(int,input().split())
#dpテーブルを作成(初期値は0)
dp = [[0 for i in range(W + 1)] for j in range(N + 1)]
#print(dp)
#N個のアイテムのvalueとweightを入れるリストを用意する
value = []
weight = []
for i in range(N):
v,w = map(int,input().split())
value.append(v)
weight.append(w)
#print(values)
#print(weights... |
s298094886 | p02315 | u210992699 | 1556871158 | Python | Python3 | py | Runtime Error | 0 | 0 | 389 | import numpy as np
N,W = map(int,input().split())
weight = [0]*N
value = [0]*N
dp = np.zeros((N+1,W+1))
for i in range(N):
value[i], weight[i] = map(int, input().split())
for i in range(N):
for j in range(W+1):
if j >= weight[i]:
dp[i+1][j] = max(dp[i][j-weight[i]]+value[i], dp[i][j])
... |
s491874698 | p02315 | u210992699 | 1556871337 | Python | Python3 | py | Runtime Error | 0 | 0 | 13 | import numpy
|
s145464814 | p02315 | u885631908 | 1443549719 | Python | Python3 | py | Runtime Error | 0 | 0 | 356 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,w = map(int,input().split())
v = [0] * (n+1)
w = [0] * (n+1)
for j in range(1, n+1):
v[j], w[j] = map(int,input().split())
dp = [[0 for i in range(w+1)] for j in range(n+1)]
for j in range(1, n+1):
for i in range(1, w+1):
dp[j][i] = max(dp[j-1][i], dp[... |
s238065636 | p02315 | u488601719 | 1449906318 | Python | Python3 | py | Runtime Error | 0 | 0 | 328 | 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(re... |
s711452610 | p02315 | u494314211 | 1479020150 | Python | Python3 | py | Runtime Error | 0 | 0 | 270 | l=[]
while(item=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 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])))
print(solve(0,W)) |
s342108980 | p02315 | u494314211 | 1479020328 | Python | Python3 | py | Runtime Error | 0 | 0 | 328 | l=[]
N,W=list(map(int,(input().split())))
while(N):
item=list(map(int,input().split))
l.append([item[1],item[0]])
N-=1
# n=4
# l=[[2,3],[1,2],[3,4],[2,2]] #w,v
# W=5
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])))
print(sol... |
s250122912 | p02315 | u494314211 | 1479020421 | Python | Python3 | py | Runtime Error | 0 | 0 | 337 | 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-=1
# n=4
# l=[[2,3],[1,2],[3,4],[2,2]] #w,v
# W=5
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])))
... |
s722282143 | p02315 | u494314211 | 1479020542 | Python | Python3 | py | Runtime Error | 0 | 0 | 330 | 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
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])))
print(s... |
s854843321 | p02315 | u494314211 | 1479020582 | 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])))... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.