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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s213594269 | p02270 | u003309334 | 1465636209 | Python | Python | py | Runtime Error | 10 | 6316 | 1200 | def moveRight(trug, start, stop):
if trug[start][1]-trug[start][0] > 1:
for i in xrange(stop-start):
trug[start+i][1] -= 1
trug[start+i+1][0] -= 1
def moveLeft(trug, start, stop):
if trug[start][1]-trug[start][0] > 1:
for i in xrange(start-stop):
trug[start-i... |
s026182379 | p02270 | u003309334 | 1465636914 | Python | Python | py | Runtime Error | 10 | 6412 | 1253 | def moveRight(trug, start, stop):
if trug[start][1]-trug[start][0] > 1:
for i in xrange(stop-start):
trug[start+i][1] -= 1
trug[start+i+1][0] -= 1
def moveLeft(trug, start, stop):
if trug[start][1]-trug[start][0] > 1:
for i in xrange(start-stop):
trug[start-i... |
s572610520 | p02270 | u742013327 | 1477383138 | Python | Python3 | py | Runtime Error | 0 | 0 | 500 | def cal(truck_num, cargos):
p = []
for i in range(len(cargos) - truck_num + 1):
if truck_num > 1:
p.append(max(sum(cargos[:i + 1]), cal(truck_num - 1, cargos[i + 1:])))
else:
return sum(cargos)
return min(p)
if __name__ == "__main__":
line = input()
truc... |
s076856852 | p02270 | u742013327 | 1477383165 | Python | Python3 | py | Runtime Error | 0 | 0 | 500 | def cal(truck_num, cargos):
p = []
for i in range(len(cargos) - truck_num + 1):
if truck_num > 1:
p.append(max(sum(cargos[:i + 1]), cal(truck_num - 1, cargos[i + 1:])))
else:
return sum(cargos)
return min(p)
if __name__ == "__main__":
line = input()
truc... |
s210396853 | p02270 | u659302741 | 1478163733 | Python | Python3 | py | Runtime Error | 60 | 7796 | 1578 | def calc_k(p, ws):
k = 1
s = 0
for w in ws:
if w > p:
return None
elif s + w <= p:
s += w
else:
k += 1
s = w
return k
def search_minimum_p_internal(lp, rp, k, ws):
"?????????P????????????????????¢?´¢??????"
cp = (lp + rp) /... |
s237093572 | p02270 | u358919705 | 1478515750 | Python | Python3 | py | Runtime Error | 50 | 7732 | 516 | n, k = map(int, input().split())
ww = [int(input()) for _ in range(n)]
def chk(p):
c = 1
s = 0
for w in ww:
if w > p:
return False
if s + w <= p:
s += w
else:
c += 1
s = w
return c <= k
def search(l, r):
if r - l < 10:
f... |
s484015856 | p02270 | u358919705 | 1478516054 | Python | Python3 | py | Runtime Error | 20 | 7756 | 557 | n, k = map(int, input().split())
ww = [int(input()) for _ in range(n)]
def chk(p):
c = 1
s = 0
for w in ww:
if w > p:
return False
if s + w <= p:
s += w
else:
c += 1
s = w
if c > k:
return False
return True
def s... |
s769757037 | p02270 | u742013327 | 1481621719 | Python | Python3 | py | Runtime Error | 0 | 0 | 863 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_B
#???????????? 17:55~
def maxHeapify(heap, index):
left_index = 2 * index
right_index = 2 * index + 1
if left_index < len(heap) and heap[left_index] > heap[index]:
largest_index = left_index
else:
largest_index = index
... |
s042335981 | p02270 | u923668099 | 1484475997 | Python | Python3 | py | Runtime Error | 20 | 7920 | 1557 | import sys
import math
def is_capable(n, k, w, P):
track = 0
cnt = 0
i = 0
while cnt < k:
if i == n:
return True
if track + w[i] > P:
track = 0
cnt += 1
else:
track += w[i]
i += 1
return False
pass
# ??\????... |
s118948428 | p02270 | u089830331 | 1484672034 | Python | Python3 | py | Runtime Error | 40 | 7776 | 719 | def get_min_p(offset, length, k, arr):
if k == 2:
min_diff = 100
p = 0
for i in range(1, length):
a = sum(arr[offset:offset + i])
b = sum(arr[offset + i:])
if abs(a - b) < min_diff:
min_diff = abs(a - b)
p = max(a, b)
#print("arr:{}, i:{}, p:{}".format(
# arr... |
s730459727 | p02270 | u918276501 | 1485111812 | Python | Python3 | py | Runtime Error | 0 | 0 | 515 | import sys
n, k = map(int, input().split())
w = tuple(map(int, sys.stdin.readlines()))
w = tuple(map(int, input().split()))
p = max(w)
s = sum(w)
if n <= k:
print(p)
elif k == 1:
print(s)
else:
a = max(p, s//k)
while True:
l = [a]
for i in range(n):
d = l[-1] - w[i]
... |
s318443766 | p02270 | u148628801 | 1487138414 | Python | Python3 | py | Runtime Error | 0 | 0 | 797 | import sys
import math
def be_able_to_convey(w, k, p):
counter = 0
cur_weight = 0
for wi in w:
if wi > p:
return False
cur_weight += wi
if(cur_weight > p):
cur_weight = wi
counter += 1
if(counter >= k):
return False
return True
fin = open("test.txt", "r")
#fin = sys.stdin
n, k = map(int,... |
s094479657 | p02270 | u831244171 | 1487341046 | Python | Python3 | py | Runtime Error | 20 | 7684 | 770 | import sys
def binarySearch(t,w,p):
left = 0
right = p
while left < right:
middle = (left + right) // 2
if hantei(t,w,middle):
left = middle + 1
else:
right = middle
return left
def hantei(t,w,p):
track_on = [0]*t
j = 0
for i in r... |
s077455999 | p02270 | u086566114 | 1488466327 | Python | Python | py | Runtime Error | 0 | 0 | 2267 | # -*- coding: utf-8 -*-
def check_numbers(cargo_weight_list, number_of_all_cargo, number_of_tracks, maximum_weight):
"""check the numbers that are loadable in tracks
Args:
cargo_weight_list: cargo weight list
number_of_tracks: the number of tracks
Returns:
the number ... |
s473266969 | p02270 | u086566114 | 1488466881 | Python | Python | py | Runtime Error | 0 | 0 | 2267 | # -*- coding: utf-8 -*-
def check_numbers(cargo_weight_list, number_of_all_cargo, number_of_tracks, maximum_weight):
"""check the numbers that are loadable in tracks
Args:
cargo_weight_list: cargo weight list
number_of_tracks: the number of tracks
Returns:
the number ... |
s005436432 | p02270 | u130834228 | 1490521096 | Python | Python3 | py | Runtime Error | 0 | 0 | 219 | n, k = map(int, input().split())
w = [0 for i in range(n)]
sumw = [0 for i in range(k)]
for i in range(n):
w[i] = input()
w.sort()
w.reverse()
for i in range(w):
sumw[min(sumw.index)] += w[i]
print(min(sumw)) |
s573185945 | p02270 | u279605379 | 1499669598 | Python | Python3 | py | Runtime Error | 0 | 0 | 512 | #ALDS1_4-D Allocation
from collections import deque
def pIsAccptbl(w,k,p):
tr = 0
c = 0
while(w):
tmp = w.popleft()
if( tr + tmp > p):
tr = 0
c += 1
else:
tr += tmp
c+=1
if c>k:return False
else:return True
n,k = input().split()
w... |
s484588951 | p02270 | u279605379 | 1499669820 | Python | Python3 | py | Runtime Error | 0 | 0 | 530 | from collections import deque
def pIsAccptbl(w,k,p):
tr = 0
c = 0
while(w):
print(c,tr)
tmp = w.popleft()
if( tr + tmp > p):
tr = tmp
c += 1
else:
tr += tmp
c+=1
if c>k:return False
else:return True
n,k = input().split()
... |
s448922612 | p02270 | u279605379 | 1499669947 | Python | Python3 | py | Runtime Error | 0 | 0 | 562 | #ALDS1_4-D Allocation
from collections import deque
def pIsAccptbl(w,k,p):
tr = 0
c = 0
while(w):
print(c,tr)
tmp = w.popleft()
if( tr + tmp > p):
tr = tmp
c += 1
else:
tr += tmp
c+=1
if c>k:return False
else:return True
... |
s098973491 | p02270 | u279605379 | 1499670325 | Python | Python3 | py | Runtime Error | 0 | 0 | 508 | #ALDS1_4-D Allocation
from collections import deque
def pIsAccptbl(w,k,p):
tr = 0
c = 0
while(w):
tmp = w.popleft()
if( tr + tmp > p):
tr = tmp
c += 1
else:
tr += tmp
c+=1
if c>k:return False
else:return True
n,k = input().split(... |
s010555079 | p02270 | u279605379 | 1499670356 | Python | Python3 | py | Runtime Error | 0 | 0 | 492 | #ALDS1_4-D Allocation
import collections
def pIsAccptbl(w,k,p):
tr = 0
c = 0
while(w):
tmp = w.popleft()
if( tr + tmp > p):
tr = tmp
c += 1
else:
tr += tmp
c+=1
if c>k:return False
else:return True
n,k = input().split()
w = colle... |
s667300575 | p02270 | u279605379 | 1499670417 | Python | Python3 | py | Runtime Error | 0 | 0 | 28 | from collectins import deque |
s026867857 | p02270 | u279605379 | 1499670446 | Python | Python3 | py | Runtime Error | 0 | 0 | 37 | from collectins import deque
print(1) |
s426923394 | p02270 | u279605379 | 1499670508 | Python | Python3 | py | Runtime Error | 0 | 0 | 538 | #ALDS1_4-D Allocation
from collections import deque
def pIsAccptbl(w,k,p):
tr = 0
c = 0
while(w):
tmp = w.popleft()
if( tr + tmp > p):
tr = tmp
c += 1
else:
tr += tmp
c+=1
if c>k:
return False
else:
return True
n,... |
s858728779 | p02270 | u279605379 | 1499670685 | Python | Python3 | py | Runtime Error | 0 | 0 | 523 | from collections import deque
def pIsAccptbl(w,k,p):
tr = 0
c = 0
while(w):
tmp = w.popleft()
if( tr + tmp > p):
tr = tmp
c += 1
else:
tr += tmp
c+=1
if c>k:
return False
else:
return True
n,k = input().split()
w ... |
s881376055 | p02270 | u279605379 | 1499670697 | Python | Python3 | py | Runtime Error | 0 | 0 | 524 | from collections import deque
def pIsAccptbl(w,k,p):
tr = 0
c = 0
while(w):
tmp = w.popleft()
if( tr + tmp > p):
tr = tmp
c += 1
else:
tr += tmp
c+=1
if c>k:
return False
else:
return True
n,k = input().split()
w ... |
s732358109 | p02270 | u279605379 | 1499670727 | Python | Python3 | py | Runtime Error | 0 | 0 | 54 | from collections import deque
w = collections.deque() |
s546334886 | p02270 | u279605379 | 1499670768 | Python | Python3 | py | Runtime Error | 0 | 0 | 526 | #ALDS1_4-D Allocation
from collections import deque
def pIsAccptbl(w,k,p):
tr = 0
c = 0
while(w):
tmp = w.popleft()
if( tr + tmp > p):
tr = tmp
c += 1
else:
tr += tmp
c+=1
if c>k:
return False
else:
return True
n,... |
s973389304 | p02270 | u279605379 | 1499670841 | Python | Python3 | py | Runtime Error | 0 | 0 | 553 | #ALDS1_4-D Allocation
from collections import deque
def pIsAccptbl(w,k,p):
tr = 0
c = 0
while(w):
tmp = w.popleft()
if( tr + tmp > p):
tr = tmp
c += 1
else:
tr += tmp
c+=1
if c>k:
return False
else:
return True
n,... |
s868178610 | p02270 | u279605379 | 1499670877 | Python | Python3 | py | Runtime Error | 0 | 0 | 546 | #ALDS1_4-D Allocation
from collections import deque
def pIsAccptbl(w,k,p):
tr = 0
c = 0
while(w):
tmp = w.popleft()
if( tr + tmp > p):
tr = tmp
c += 1
else:
tr += tmp
c+=1
if c>k:
return False
else:
return True
n,... |
s661294511 | p02270 | u279605379 | 1499740642 | Python | Python3 | py | Runtime Error | 0 | 0 | 1112 | from collections import deque
def cndP(l,n,p1,p2):
d = set()
length = len(l)
for i in range(length-n+1):
s = sum(l[i:i+n])
#print("s:",s)
if p2 == None:
if p1 < s:
d.add(s)
else:
if p1 < c < p2:
d.add(s)
return sort... |
s184687851 | p02270 | u279605379 | 1499740672 | Python | Python3 | py | Runtime Error | 0 | 0 | 1012 | from collections import deque
def cndP(l,n,p1,p2):
d = set()
length = len(l)
for i in range(length-n+1):
s = sum(l[i:i+n])
if p2 == None:
if p1 < s:
d.add(s)
else:
if p1 < c < p2:
d.add(s)
return sorted(d)
def pIsAccptbl(w... |
s691240671 | p02270 | u279605379 | 1499825757 | Python | Python3 | py | Runtime Error | 0 | 0 | 1100 | from collections import deque
def cndP(l,n,p1,p2):
d = set()
length = len(l)
for i in range(length-n+1):
s = sum(l[i:i+n])
if p2 == None:
if p1 < s:
d.add(s)
else:
if p1 < s < p2:
d.add(s)
return sorted(d)
def pIsAccptbl(w... |
s317196787 | p02270 | u279605379 | 1499825768 | Python | Python3 | py | Runtime Error | 0 | 0 | 1061 | from collections import deque
def cndP(l,n,p1,p2):
d = set()
length = len(l)
for i in range(length-n+1):
s = sum(l[i:i+n])
if p2 == None:
if p1 < s:
d.add(s)
else:
if p1 < s < p2:
d.add(s)
return sorted(d)
def pIsAccptbl(w... |
s148720496 | p02270 | u279605379 | 1499827384 | Python | Python3 | py | Runtime Error | 0 | 0 | 1061 | from collections import deque
def cndP(l,n,p1,p2):
d = set()
length = len(l)
for i in range(length-n+1):
s = sum(l[i:i+n])
if p2 == None:
if p1 < s:
d.add(s)
else:
if p1 < s < p2:
d.add(s)
return sorted(d)
def pIsAccptbl(w... |
s293570954 | p02270 | u279605379 | 1499910878 | Python | Python3 | py | Runtime Error | 0 | 0 | 798 | from collections import deque
def cndP(w):
if len(w)>1:
x = w.pop()
cndP(w.copy())
w.append(x)
s = 0
while(len(w)>0):
s += w.pop()
st.add(s)
else:
st.add(w[0])
def pIsAccptbl(w,k,p):
tr = 0
c = 0
d = w.copy()
while... |
s254153666 | p02270 | u279605379 | 1499910910 | Python | Python3 | py | Runtime Error | 0 | 0 | 1254 | from collections import deque
def cndP(l,n,p1,p2):
d = set()
min = sum(l[:])
length = len(l)
for i in range(length-n+1):
s = sum(l[i:i+n])
if s < min:
min = s
if p2 == None:
if p1 < s:
d.add(s)
else:
if p1 < s < p2:
... |
s338477852 | p02270 | u279605379 | 1499911043 | Python | Python3 | py | Runtime Error | 0 | 0 | 721 | from collections import deque
def cndP(w):
if len(w)>1:
x = w.pop()
cndP(w.copy())
w.append(x)
s = 0
while(len(w)>0):
s += w.pop()
st.add(s)
else:
st.add(w[0])
def pIsAccptbl(w,k,p):
tr = 0
c = 0
d = w.copy()
while... |
s689710759 | p02270 | u279605379 | 1499911057 | Python | Python3 | py | Runtime Error | 0 | 0 | 698 | from collections import deque
def cndP(w):
if len(w)>1:
x = w.pop()
cndP(w.copy())
w.append(x)
s = 0
while(len(w)>0):
s += w.pop()
st.add(s)
else:
st.add(w[0])
def pIsAccptbl(w,k,p):
tr = 0
c = 0
d = w.copy()
while... |
s582556677 | p02270 | u279605379 | 1499911071 | Python | Python3 | py | Runtime Error | 0 | 0 | 1382 | from collections import deque
def cndP(w):
if len(w)>1:
x = w.pop()
cndP(w.copy())
w.append(x)
s = 0
while(len(w)>0):
s += w.pop()
st.add(s)
else:
st.add(w[0])
def pIsAccptbl(w,k,p):
tr = 0
c = 0
d = w.copy()
while... |
s705607465 | p02270 | u279605379 | 1499911077 | Python | Python3 | py | Runtime Error | 0 | 0 | 1375 | from collections import deque
def cndP(w):
if len(w)>1:
x = w.pop()
cndP(w.copy())
w.append(x)
s = 0
while(len(w)>0):
s += w.pop()
st.add(s)
else:
st.add(w[0])
def pIsAccptbl(w,k,p):
tr = 0
c = 0
d = w.copy()
while... |
s283773204 | p02270 | u279605379 | 1499911102 | Python | Python3 | py | Runtime Error | 0 | 0 | 1309 | from collections import deque
def cndP(w):
if len(w)>1:
x = w.pop()
cndP(w.copy())
w.append(x)
s = 0
else:
st.add(w[0])
def pIsAccptbl(w,k,p):
tr = 0
c = 0
d = w.copy()
while(d):
tmp = d.popleft()
if(tmp > p):
return ... |
s401842439 | p02270 | u279605379 | 1499911114 | Python | Python3 | py | Runtime Error | 0 | 0 | 1275 | from collections import deque
def cndP(w):
if len(w)>1:
x = w.pop()
cndP(w.copy())
else:
st.add(w[0])
def pIsAccptbl(w,k,p):
tr = 0
c = 0
d = w.copy()
while(d):
tmp = d.popleft()
if(tmp > p):
return False
if( tr + tm... |
s675816552 | p02270 | u279605379 | 1499911121 | Python | Python3 | py | Runtime Error | 0 | 0 | 1358 | from collections import deque
def cndP(w):
if len(w)>1:
x = w.pop()
w.append(x)
s = 0
while(len(w)>0):
s += w.pop()
st.add(s)
else:
st.add(w[0])
def pIsAccptbl(w,k,p):
tr = 0
c = 0
d = w.copy()
while(d):
tmp = d.p... |
s085635459 | p02270 | u279605379 | 1499911150 | Python | Python3 | py | Runtime Error | 0 | 0 | 1380 | from collections import deque
def cndP(w):
if len(w)>1:
x = w.pop()
cndP(w.copy())
w.append(x)
s = 0
while(len(w)>0):
s += w.pop()
st.add(s)
else:
st.add(w[0])
def pIsAccptbl(w,k,p):
tr = 0
c = 0
d = w.copy()
while... |
s077917976 | p02270 | u279605379 | 1499911279 | Python | Python3 | py | Runtime Error | 0 | 0 | 1382 | from collections import deque
def cndP(w):
if len(w)>1:
x = w.pop()
cndP(w.copy())
w.append(x)
s = 0
while(len(w)>0):
s += w.pop()
st.add(s)
else:
st.add(w[0])
def pIsAccptbl(w,k,p):
tr = 0
c = 0
d = w.copy()
while... |
s317761402 | p02270 | u279605379 | 1499912413 | Python | Python3 | py | Runtime Error | 30 | 8144 | 895 | from collections import deque
def copyDeque(d):
x = deque()
for i in d:
x.append(i)
return x
def cndP(w):
if len(w)>1:
x = w.pop()
cndP(copyDeque(w))
w.append(x)
s = 0
while(len(w)>0):
s += w.pop()
st.add(s)
else:
st.a... |
s941778932 | p02270 | u279605379 | 1499912426 | Python | Python3 | py | Runtime Error | 30 | 8160 | 895 | from collections import deque
def copyDeque(d):
x = deque()
for i in d:
x.append(i)
return x
def cndP(w):
if len(w)>1:
x = w.pop()
cndP(copyDeque(w))
w.append(x)
s = 0
while(len(w)>0):
s += w.pop()
st.add(s)
else:
st.a... |
s151897430 | p02270 | u279605379 | 1499914229 | Python | Python3 | py | Runtime Error | 0 | 0 | 961 | from collections import deque
sys.setrecursionlimit(100000)
def copyDeque(d):
x = deque()
for i in d:
x.append(i)
return x
def cndP(w):
if len(w)>1:
x = w.pop()
cndP(copyDeque(w))
w.append(x)
s = 0
while(len(w)>0):
s += w.pop()
s... |
s386706413 | p02270 | u279605379 | 1499914258 | Python | Python3 | py | Runtime Error | 0 | 0 | 924 | from collections import deque
import sys
sys.setrecursionlimit(100000)
def copyDeque(d):
x = deque()
for i in d:
x.append(i)
return x
def cndP(w):
if len(w)>1:
x = w.pop()
cndP(copyDeque(w))
w.append(x)
s = 0
while(len(w)>0):
s += w.pop()
... |
s520470033 | p02270 | u279605379 | 1500345279 | Python | Python3 | py | Runtime Error | 0 | 0 | 1077 | from collections import deque
def isPa(w,k,p):
counter = 0
s = 0
n = 1
wlen = len(w)
while(True):
if( sum([s:s+n]) >= p):
s = s+n
n = 1
counter += 1
else:
n += 1
if( s+n == len(a)):
counter += 1
... |
s516732926 | p02270 | u279605379 | 1500345428 | Python | Python3 | py | Runtime Error | 0 | 0 | 1073 | from collections import deque
def isPa(w,k,p):
counter = 0
s = 0
n = 1
wlen = len(w)
while(True):
if( sum(w[s:s+n]) >= p):
s = s+n
n = 1
counter += 1
else:
n += 1
if( s+n == len(a)):
counter += 1
... |
s398252290 | p02270 | u519227872 | 1501760693 | Python | Python3 | py | Runtime Error | 0 | 0 | 505 | n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = map(int, input().split())
def binarySearch(array, target):
l = len(array)
first_half = array[:l//2]
second_half = array[l//2:]
if first_half == []:
return False
if first_half[-1] == target:
return True
eli... |
s357280531 | p02270 | u856963614 | 1509984967 | Python | Python3 | py | Runtime Error | 30 | 7808 | 756 |
nk=input().split()
n=int(nk[0])
k=int(nk[1])
weight=[int(input()) for i in range(n)]
def ok(m):
load=0
track=1
# sum all the weight and count the track number we need
for i in range(n):
load+=weight[i]
if load==m:
load=0
if i!=n-1:
track+=1
... |
s667737564 | p02270 | u426534722 | 1516638923 | Python | Python3 | py | Runtime Error | 0 | 0 | 465 | import sys
readline = sys.stdin.readline
N, K = map(int, input().split())
W = tuple(int(readline()) for _ in range(n))
ma = max(W)
def check(x):
if x < ma:
return False
use = 1
rest = x
for w in W:
if rest >= w:
rest -= w
else:
rest = x - w
use... |
s061977688 | p02270 | u426534722 | 1516639182 | Python | Python3 | py | Runtime Error | 0 | 0 | 466 | import sys
readline = sys.stdin.readline
N, K = map(int, input().split())
W = {map(int, sys.stdin.read().splitlines())}
ma = max(W)
def check(x):
if x < ma:
return False
use = 1
rest = x
for w in W:
if rest >= w:
rest -= w
else:
rest = x - w
us... |
s789863230 | p02270 | u426534722 | 1516639543 | Python | Python3 | py | Runtime Error | 0 | 0 | 464 | import sys
readline = sys.stdin.readline
N, K = map(int, input().split())
W = tuple(map(int, sys.stdin.splitlines()))
ma = max(W)
def check(x):
if x < ma:
return False
use = 1
rest = x
for w in W:
if rest >= w:
rest -= w
else:
rest = x - w
use ... |
s062802487 | p02270 | u138546245 | 1523868937 | Python | Python3 | py | Runtime Error | 0 | 0 | 734 | def allocate(count, weights):
def loadable_counts(maxweight):
n = 0
l = 0
c = count
for w in weights:
l += w
if l > maxweight:
l = w
c -= 1
if c <= 0:
return n
n += 1
return n... |
s727338188 | p02270 | u605879293 | 1523947222 | Python | Python3 | py | Runtime Error | 20 | 5656 | 594 | from itertools import combinations
def func(w, partition):
sum_list = [sum(w[0:partition[0]])]
for i in range(len(partition)):
if i < len(partition) - 1:
sum_list.append(sum(w[partition[i]:partition[i+1]]))
else:
sum_list.append(sum(w[partition[i]:]))
return max(sum... |
s755468601 | p02270 | u005964097 | 1525926023 | Python | Python3 | py | Runtime Error | 0 | 0 | 542 | def min_sufficient_load(w, k):
return check(w, k, 0, sum(w))
def check(w, k, p1, p2):
trunk_no = 1
temp = 0
m = 1+(p1 + p2)>>1
for i in w:
if temp + i <= m:
temp += i
else:
trunk_no += 1
temp = i
if trunk_no > k:
return check(w, k, m,... |
s431643629 | p02270 | u005964097 | 1525951873 | Python | Python3 | py | Runtime Error | 0 | 0 | 673 | def min_sufficient_load(w, k):
return check(w, k, 0, sum(w))
def check(w, k, p1, p2):
trunk_no = 1
temp = 0
m = 1+(p1 + p2)>>1
for i in w:
if temp + i <= m:
temp += i
if temp==m:
trunk_no+=1
temp = 0
else:
tr... |
s889666573 | p02270 | u005964097 | 1525951922 | Python | Python3 | py | Runtime Error | 20 | 5600 | 655 | def min_sufficient_load(w, k):
return check(w, k, 0, sum(w))
def check(w, k, p1, p2):
trunk_no = 1
temp = 0
m = 1+(p1 + p2)>>1
for i in w:
if temp + i <= m:
temp += i
if temp==m:
trunk_no+=1
temp = 0
else:
trunk_no... |
s621986512 | p02270 | u005964097 | 1525952068 | Python | Python3 | py | Runtime Error | 20 | 5600 | 655 | def min_sufficient_load(w, k):
return check(w, k, 0, sum(w))
def check(w, k, p1, p2):
trunk_no = 1
temp = 0
m = 1+(p1 + p2)>>1
for i in w:
if temp + i <= m:
temp += i
if temp==m:
trunk_no+=1
temp = 0
else:
trunk_no... |
s951921904 | p02270 | u005964097 | 1525952079 | Python | Python3 | py | Runtime Error | 0 | 0 | 655 | def min_sufficient_load(w, k):
return check(w, k, 0, sum(w))
def check(w, k, p1, p2):
trunk_no = 1
temp = 0
m = 1+(p1 + p2)>>1
for i in w:
if temp + i <= m:
temp += i
if temp==m:
trunk_no+=1
temp = 0
else:
trunk_no... |
s422198263 | p02270 | u684241248 | 1527588366 | Python | Python3 | py | Runtime Error | 190 | 5952 | 647 | n, k = [int(_) for _ in input().split()]
ary = [int(input()) for _ in range(n)]
def search_v(p):
v = 0
w = 0
tmp_k = 1
ind = 0
while True:
if tmp_k > k:
return v
if ind == n:
return n
tmp = ary[ind]
if w + tmp <= p:
w += tmp
... |
s478805389 | p02270 | u684241248 | 1527588469 | Python | Python3 | py | Runtime Error | 20 | 5604 | 642 | n, k = [int(_) for _ in input().split()]
ary = [int(input()) for _ in range(n)]
def search_v(p):
v = 0
w = 0
tmp_k = 1
ind = 0
while True:
if tmp_k > k:
return v
if ind == n:
return n
tmp = ary[ind]
if w + tmp <= p:
w += tmp
... |
s035255242 | p02270 | u986478725 | 1527656378 | Python | Python3 | py | Runtime Error | 370 | 7528 | 1168 | # ALDS1_4_D.
# アロケーション。
W = [0 for i in range(100000)]
def intinput():
a = input().split()
for i in range(len(a)):
a[i] = int(a[i])
return a
def canLoad(P, n, k):
# P以下の条件下ですべての荷物を積めるか否か。
# Wには荷物の情報が入ってる。nは荷物の個数、kはトラックの台数。
# i > nで返ればTrue.
sumOfLoad = 0
numOfPackage = 0
nu... |
s839011165 | p02270 | u436634575 | 1400893808 | Python | Python3 | py | Runtime Error | 0 | 0 | 471 | def check(p):
s = w[0]
track = 1
for i in range(1, n):
if s + w[i] <= p:
s += w[i]
else:
track += 1
if track > k: return False
s = w[i]
return True
n, k = map(int, input().strip().split())
w = []
for i in range(n):
w.append(int(input()... |
s517762655 | p02271 | u657361950 | 1530970150 | Python | Python3 | py | Runtime Error | 13690 | 5608 | 423 |
def solve(a, m):
return solve_(a, 0, m)
def solve_(a, i, m):
res = False
if m == 0:
res = True
elif i >= len(a):
res = False
else:
res1 = solve_(a, i + 1, m)
res2 = solve_(a, i + 1, m - a[i])
res = res1 or res2
return res
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(... |
s153290246 | p02271 | u153665391 | 1531061379 | Python | Python3 | py | Runtime Error | 3220 | 5612 | 630 | N = int(input())
A = sorted(list(map(int, input().split())))
Q = int(input())
M = list(map(int, input().split()))
def exhastive_search(target, head, sum):
for i in range(head, N):
sum += A[i]
if target == sum:
return True
elif target > sum:
if exhastive_search(target... |
s805049719 | p02271 | u153665391 | 1531061673 | Python | Python3 | py | Runtime Error | 3200 | 5608 | 617 | N = int(input())
A = sorted(list(map(int, input().split())))
Q = int(input())
M = list(map(int, input().split()))
def exhastive_search(target, head, sum):
for i in range(head, N):
sum += A[i]
if target == sum:
return True
elif target > sum:
if exhastive_search(target... |
s609081576 | p02271 | u153665391 | 1531103004 | Python | Python3 | py | Runtime Error | 3200 | 5612 | 612 | N = int(input())
A = list(map(int, input().split()))
Q = int(input())
M = list(map(int, input().split()))
def exhastive_search(target, head, sum):
for i in range(head, N):
sum += A[i]
if target == sum:
return True
elif target > sum:
if exhastive_search(target, i+1, s... |
s823017417 | p02271 | u153665391 | 1531103521 | Python | Python3 | py | Runtime Error | 3180 | 5608 | 621 | N = int(input())
A = sorted(list(map(int, input().split())))
Q = int(input())
M = list(map(int, input().split()))
def exhastive_search(target, head, sum):
for i in range(head, N):
sum += A[i]
if target == sum:
return True
elif target > sum:
if exhastive_search(target... |
s832860466 | p02271 | u153665391 | 1531104099 | Python | Python3 | py | Runtime Error | 3290 | 5608 | 691 | N = int(input())
A = sorted(list(map(int, input().split())))
Q = int(input())
M = list(map(int, input().split()))
def exhastive_search(target, head, sum):
for i in range(head, N):
sum += A[i]
if target == sum:
return True
elif target > sum:
if exhastive_search(target... |
s219444381 | p02271 | u153665391 | 1531214482 | Python | Python3 | py | Runtime Error | 8210 | 5612 | 401 | N = int(input())
A = list(map(int, input().split()))
Q = int(input())
M = list(map(int, input().split()))
def solve(idx, target):
if target == 0:
return True
if idx >= N:
return False
if solve(idx+1, target) or solve(idx+1, target-A[idx]):
return True
return False
for target i... |
s109232328 | p02271 | u153665391 | 1531215205 | Python | Python3 | py | Runtime Error | 9250 | 5612 | 451 | N = int(input())
A = sorted(list(map(int, input().split())))
Q = int(input())
M = list(map(int, input().split()))
def solve(idx, target):
if target == 0:
return True
elif target < 0:
return False
if idx >= N:
return False
if solve(idx+1, target) or solve(idx+1, target-A[idx]):
... |
s571492788 | p02271 | u316584871 | 1531287684 | Python | Python3 | py | Runtime Error | 13830 | 7036 | 365 | n = int(input())
seq = list(map(int, input().split()))
q = int(input())
mlist = list(map(int, input().split()))
def check(i, m):
if m == 0:
return 'yes'
elif i >= n:
return 'no'
res = check(i+1, m) + check(i+1, m - seq[i])
return res
for m in mlist:
if('yes' in check(0, m)):
... |
s278343865 | p02271 | u316584871 | 1531287853 | Python | Python3 | py | Runtime Error | 11600 | 5612 | 352 | n = int(input())
seq = list(map(int, input().split()))
q = int(input())
mlist = list(map(int, input().split()))
def check(i, m):
if m == 0:
return 1
elif i >= n:
return 0
res = check(i+1, m) + check(i+1, m - seq[i])
return res
for m in mlist:
if(check(0,m) > 0):
print('yes'... |
s924727950 | p02271 | u316584871 | 1531288128 | Python | Python3 | py | Runtime Error | 11640 | 5612 | 355 | n = int(input())
seq = list(map(int, input().split()))
q = int(input())
mlist = list(map(int, input().split()))
def check(i, m):
if m == 0:
return True
elif i >= n:
return False
res = check(i+1, m) + check(i+1, m - seq[i])
return res
for m in mlist:
if(check(0,m)):
print('y... |
s228136819 | p02271 | u316584871 | 1531288737 | Python | Python3 | py | Runtime Error | 11830 | 5612 | 466 | n = int(input())
seq = list(map(int, input().split()))
q = int(input())
mlist = list(map(int, input().split()))
global mins
mins = min(seq)
global sums
sums = sum(mlist)
def check(i, m):
if m == 0:
return True
elif i >= n:
return False
res = check(i+1, m) + check(i+1, m - seq[i])
return... |
s208138380 | p02271 | u316584871 | 1531288971 | Python | Python3 | py | Runtime Error | 3010 | 5608 | 485 | n = int(input())
seq = list(map(int, input().split()))
q = int(input())
mlist = list(map(int, input().split()))
global mins
mins = min(seq)
sums = 0
for a in seq:
sums += a
def check(i, m):
if m == 0:
return True
elif i >= n or mins > m:
return False
res = check(i+1, m) + check(i+1, m -... |
s812429046 | p02271 | u316584871 | 1531289455 | Python | Python3 | py | Runtime Error | 2770 | 5612 | 489 | n = int(input())
seq = list(map(int, input().split()))
q = int(input())
mlist = list(map(int, input().split()))
mins = min(seq)
sums = 0
for a in seq:
sums += a
def check(i, m):
global mins
if m == 0:
return True
elif i >= n or mins > m:
return False
res = check(i+1, m) + check(i+1,... |
s071810765 | p02271 | u094978706 | 1535699112 | Python | Python3 | py | Runtime Error | 0 | 0 | 574 | import numpy as np
n = int(input())
A = np.array(list(map(int, input().split() )))
q = int(input())
m = list(map(int, input().split()))
def deci_to_bin_list(num, n):
out = np.zeros(n, dtype='int')
for i in range(n-1, -1, -1):
denom = 2**i
out[i] = num // denom
num = num % denom
ret... |
s333414324 | p02271 | u580607517 | 1421035959 | Python | Python | py | Runtime Error | 0 | 0 | 308 | def solve(i, m):
if i >= n:
return m == 0
if solve(i + 1, m):
return True
if solve(i + 1, m - A[i]):
return True
return False
n = int(raw_input())
A = map(int,raw_input().split())
q = int(raw_input())
for i in xrange(q):
m = int(raw_input())
if solve(0, m):
print "yes"
else:
print "no" |
s655861556 | p02271 | u580607517 | 1421036202 | Python | Python | py | Runtime Error | 19930 | 4220 | 311 | def solve(i, m):
if i >= n:
return m == 0
if solve(i + 1, m):
return True
if solve(i + 1, m - A[i]):
return True
return False
n = int(raw_input())
A = map(int,raw_input().split())
q = int(raw_input())
M = map(int, raw_input().split())
for m in M:
if solve(0, m):
print "yes"
else:
print "no" |
s179639023 | p02271 | u580607517 | 1421036278 | Python | Python | py | Runtime Error | 19930 | 4220 | 311 | def solve(i, m):
if i >= n:
return m == 0
if solve(i + 1, m):
return True
if solve(i + 1, m - A[i]):
return True
return False
n = int(raw_input())
A = map(int,raw_input().split())
q = int(raw_input())
M = map(int, raw_input().split())
for m in M:
if solve(0, m):
print "yes"
else:
print "no" |
s619722506 | p02271 | u567380442 | 1421406052 | Python | Python3 | py | Runtime Error | 0 | 0 | 251 | n = input()
a = list(map(int, input().split()))
q = input()
aset = set()
for i in range(1, len(a) + 1):
aset |= set(sum(combi) for combi in itertools.combinations(a, i))
for m in map(int, input().split()):
print('yes' if m in aset else 'no') |
s692542768 | p02271 | u879226672 | 1427351875 | Python | Python | py | Runtime Error | 19930 | 74512 | 446 | n = int(raw_input())
A = map(int,raw_input().split())
q = int(raw_input())
mi = map(int,raw_input().split())
S = []
for k in range(1,2**len(A)):
S.append(map(int,list((format(k,'b').zfill(len(A))))))
for m in mi:
for k in range(len(S)):
tot = 0
for j in range(len(S[k])):
if S[k][j]... |
s633381200 | p02271 | u879226672 | 1430836835 | Python | Python | py | Runtime Error | 19930 | 66172 | 449 | n = int(raw_input())
A = map(int,raw_input().split())
q = int(raw_input())
mi = map(int,raw_input().split())
S = []
for k in xrange(1,2**len(A)):
S.append(map(int,list((format(k,'b').zfill(len(A))))))
for m in mi:
for k in xrange(len(S)):
tot = 0
for j in xrange(len(S[k])):
if S[k]... |
s675089109 | p02271 | u689297737 | 1432860481 | Python | Python | py | Runtime Error | 19930 | 4240 | 788 | # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_A
# Exhaustive Search
# Result:
import sys
def calc(target, cur_sum, ary, ary_idx):
new_sum = cur_sum + ary[ary_idx]
if new_sum == target:
return True
ary_idx += 1
if ary_idx == len(ary):
return False
return calc(tar... |
s487105985 | p02271 | u140201022 | 1434385981 | Python | Python | py | Runtime Error | 19930 | 4240 | 534 | n=int(raw_input())
a=map(int,raw_input().split())
q=int(raw_input())
m=map(int,raw_input().split())
ans=chk=0
bits=(1<<n)-1
for i in m:
p=bits
flag=0
while p:
chk=str(bin(p))[2:]
chk='0'*(n-len(chk))+chk
p-=1
h=0
for j,k in enumerate(chk):
if k=='1':
... |
s421903282 | p02271 | u604774382 | 1437313345 | Python | Python | py | Runtime Error | 0 | 0 | 392 | def solve( p, t ):
global isExist
global n
global A
isExist[ t ] = True
if p < n:
solve( p+1, t-A[p] )
solve( p+1, t )
isExist = [False]*2001
n = int( raw_input() )
A = map( int, raw_input().split( " " ) )
q = int( raw_input() )
M = map( int, raw_input().split( " " ) )
s = sum( A )
solve( 0, s )
for i in ran... |
s215680089 | p02271 | u604774382 | 1437313504 | Python | Python3 | py | Runtime Error | 0 | 0 | 376 | def solve( p, t ):
global isExist
global n
global A
isExist[ t ] = True
if p < n:
solve( p+1, t-A[p] )
solve( p+1, t )
isExist = [False]*2001
n = int( input() )
A = map( int, input().split( " " ) )
q = int( input() )
M = map( int, input().split( " " ) )
s = sum( A )
solve( 0, s )
for i in range( 0, q ):
if ... |
s282138191 | p02271 | u604774382 | 1437313781 | Python | Python3 | py | Runtime Error | 0 | 0 | 404 | def solve( p, t ):
global isExist
global n
global A
isExist[ t ] = True
if p < n:
solve( p+1, t-A[p] )
solve( p+1, t )
isExist = [False]*2001
n = int( input() )
A = [ int( val ) for val in input().split( " " ) ]
q = int( input() )
M = [ int( val ) for val in input().split( " " ) ]
s = sum( A )
solve( 0, s )
... |
s608212315 | p02271 | u604774382 | 1437313957 | Python | Python | py | Runtime Error | 0 | 0 | 437 | def solve( p, t ):
global isExist
global n
global A
isExist[ t ] = True
if p < n:
solve( p+1, t-A[p] )
solve( p+1, t )
else:
return
isExist = [False]*2001
n = int( raw_input() )
A = [ int( val ) for val in raw_input().split( ' ' ) ]
q = int( raw_input() )
M = [ int( val ) for val in raw_input().split( ' ... |
s763891215 | p02271 | u604774382 | 1437314368 | Python | Python | py | Runtime Error | 0 | 0 | 373 | isExist = [False]*2001
n = int( raw_input() )
A = [ int( val ) for val in raw_input().split( ' ' ) ]
for i in A:
for j in range( 2000-i, 0, -1 ):
if isExist[j]:
isExist[ i+j ] = True
isExist[i] = True
q = int( raw_input() )
M = [ int( val ) for val in raw_input().split( ' ' ) ]
for i in range( 0, q ):
if isE... |
s590375542 | p02271 | u604774382 | 1437314430 | Python | Python3 | py | Runtime Error | 0 | 0 | 357 | isExist = [False]*2001
n = int( input() )
A = [ int( val ) for val in input().split( ' ' ) ]
for i in A:
for j in range( 2000-i, 0, -1 ):
if isExist[j]:
isExist[ i+j ] = True
isExist[i] = True
q = int( input() )
M = [ int( val ) for val in input().split( ' ' ) ]
for i in range( 0, q ):
if isExist[ M[i] ]:
... |
s064432568 | p02271 | u604774382 | 1437315348 | Python | Python3 | py | Runtime Error | 0 | 0 | 204 | isExist = [False]*2001
n = int( input() )
A = [ int( val ) for val in input().split( ' ' ) ]
q = int( input() )
M = [ int( val ) for val in input().split( ' ' ) ]
for i in range( 0, q ):
print( "yes" ) |
s821408640 | p02271 | u604774382 | 1437315374 | Python | Python3 | py | Runtime Error | 0 | 0 | 179 | n = int( input() )
A = [ int( val ) for val in input().split( ' ' ) ]
q = int( input() )
M = [ int( val ) for val in input().split( ' ' ) ]
for i in range( 0, q ):
print( "yes" ) |
s557574965 | p02271 | u604774382 | 1437315490 | Python | Python3 | py | Runtime Error | 0 | 0 | 179 | d = int( input() )
c = [ int( val ) for val in input().split( " " ) ]
f = int( input() )
b = [ int( val ) for val in input().split( " " ) ]
for i in range( 0, 3 ):
print( "yes" ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.