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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s617167660 | p01144 | u947762778 | 1508049434 | Python | Python3 | py | Runtime Error | 40000 | 9364 | 437 | while True:
n, m = map(int, input().split())
dpList = []
if n + m < 1:
break
for i in range(n):
row = list(map(int,input().split()))
dpList.append(row)
dpList = sorted(dpList, key = lambda x:x[1], reverse = True)
num = 0
for i in range(n):
if m >= dpList[i... |
s352754660 | p01144 | u947762778 | 1508049535 | Python | Python3 | py | Runtime Error | 40000 | 9276 | 442 | while True:
n, m = map(int, input().split())
dpList = []
if (n,m) == (0,0):
break
for i in range(n):
row = list(map(int,input().split()))
dpList.append(row)
dpList = sorted(dpList, key = lambda x:x[1], reverse = True)
num = 0
for i in range(n):
if m >= dpL... |
s134565221 | p01144 | u797673668 | 1510312588 | Python | Python3 | py | Runtime Error | 0 | 0 | 347 | while True:
n, m = map(int, input().split())
if n == 0:
break
risks = [(p, d) for d, p in (map(int, input().split()) for _ in range(n))]
risks.sort()
while m:
p, d = risks.pop()
if d >= m:
remain = p * (d - m)
break
m -= d
print(remain + su... |
s638291744 | p01144 | u797673668 | 1510312634 | Python | Python3 | py | Runtime Error | 0 | 0 | 362 | while True:
n, m = map(int, input().split())
if n == 0:
break
risks = [(p, d) for d, p in (map(int, input().split()) for _ in range(n))]
risks.sort()
remain = 0
while m:
p, d = risks.pop()
if d >= m:
remain = p * (d - m)
break
m -= d
pr... |
s216161886 | p01144 | u624914682 | 1524481364 | Python | Python3 | py | Runtime Error | 0 | 0 | 755 | # coding: utf-8
n,m=map(int,input().split())
while n!=0:
d=[]
p=[]
for i in range(n):
d_i,p_i=map(int,input().split())
d.append(d_i)
p.append((p_i,i)) #タプルでインデックス情報を付加
#単位長さあたりの期待値で降順ソート
p.sort(key=lambda x:-x[0])
#警備がいない場合の期待値を求める
hazard=0
for i i... |
s272907338 | p01144 | u624914682 | 1524481395 | Python | Python3 | py | Runtime Error | 0 | 0 | 755 | # coding: utf-8
n,m=map(int,input().split())
while n!=0:
d=[]
p=[]
for i in range(n):
d_i,p_i=map(int,input().split())
d.append(d_i)
p.append((p_i,i)) #タプルでインデックス情報を付加
#単位長さあたりの期待値で降順ソート
p.sort(key=lambda x:-x[0])
#警備がいない場合の期待値を求める
hazard=0
for i i... |
s405606143 | p01144 | u089116225 | 1524489354 | Python | Python3 | py | Runtime Error | 0 | 0 | 464 | while True:
n, m = map(int, input().split())
if n == 0:
break
else:
s = 0
l = []
for _ in range(n):
d, p = map(int, input().split())
s += d * p
l.append((p,d))
l.sort()
while m > 0:
a, b = l.pop()
if... |
s299687517 | p01144 | u089116225 | 1524489417 | Python | Python3 | py | Runtime Error | 0 | 0 | 464 | while True:
n, m = map(int, input().split())
if n == 0:
break
else:
s = 0
l = []
for _ in range(n):
d, p = map(int, input().split())
s += d * p
l.append((p,d))
l.sort()
while m > 0:
a, b = l.pop()
if... |
s116674861 | p01144 | u209989098 | 1528953466 | Python | Python3 | py | Runtime Error | 0 | 0 | 460 | da = list(map(int,input().split()))
k = [[0]*2]*10000
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = map(int,input().split())
su += k[i][0] * k[i][1]
sorted(k)
while da[1] != 0:
if da[1] > k[j][0]:
su -= k[j][0]* k[j][1]
da[1] -= k[j][... |
s227430186 | p01144 | u209989098 | 1528954990 | Python | Python3 | py | Runtime Error | 0 | 0 | 545 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10000)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = list(map(int,input().split()))
su += k[i][0] * k[i][1]
sorted(k,reverse = True)
while da[1] != 0:
if da[1] >=... |
s206993225 | p01144 | u209989098 | 1528955190 | Python | Python3 | py | Runtime Error | 0 | 0 | 545 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10000)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = list(map(int,input().split()))
su += k[i][0] * k[i][1]
sorted(k,reverse = True)
while da[1] != 0:
if da[1] >=... |
s735878234 | p01144 | u209989098 | 1528957213 | Python | Python3 | py | Runtime Error | 0 | 0 | 605 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10000)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = list(map(int,input().split()))
su += k[i][0] * k[i][1]
sorted(k,key = lambda x: x[1],reverse = True)
while da[1... |
s419092644 | p01144 | u209989098 | 1528957908 | Python | Python3 | py | Runtime Error | 0 | 0 | 545 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10000)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = list(map(int,input().split()))
su += k[i][0] * k[i][1]
sorted(k,reverse = True)
while da[1] != 0:
if da[1] >=... |
s554609111 | p01144 | u209989098 | 1528958884 | Python | Python3 | py | Runtime Error | 0 | 0 | 595 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = list(map(int,input().split()))
su += k[i][0] * k[i][1]
sorted(k,key = lambda x: x[1],reverse = True)
while da[1... |
s960722853 | p01144 | u209989098 | 1528959368 | Python | Python3 | py | Runtime Error | 0 | 0 | 624 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = list(map(int,input().split()))
su += k[i][0] * k[i][1]
sorted(k,key = lambda x: x[1],reverse = True)
while... |
s988370999 | p01144 | u209989098 | 1528959798 | Python | Python3 | py | Runtime Error | 0 | 0 | 631 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = list(map(int,input().split()))
su += k[i][0] * k[i][1]
sorted(k,key = lambda x: x[1],reverse = True)
whil... |
s434598010 | p01144 | u209989098 | 1528959862 | Python | Python3 | py | Runtime Error | 0 | 0 | 626 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = list(map(int,input().split()))
su += k[i][0] * k[i][1]
sorted(k,key = lambda x: x[1],reverse = True)
whil... |
s018804062 | p01144 | u209989098 | 1528960019 | Python | Python3 | py | Runtime Error | 0 | 0 | 630 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = list(map(int,input().split()))
su += k[i][0] * k[i][1]
sorted(k,key = lambda x: x[1],reverse = True)
whil... |
s897996990 | p01144 | u209989098 | 1528960374 | Python | Python3 | py | Runtime Error | 0 | 0 | 627 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = list(map(int,input().split()))
su += k[i][0] * k[i][1]
sorted(k,key = lambda x: x[1],reverse = True)
whil... |
s797355250 | p01144 | u209989098 | 1528968331 | Python | Python3 | py | Runtime Error | 0 | 0 | 625 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = list(map(int,input().split()))
su += k[i][0] * k[i][1]
sorted(k,key = lambda x: x[1],reverse = True)
while da... |
s121492726 | p01144 | u209989098 | 1528968360 | Python | Python3 | py | Runtime Error | 0 | 0 | 624 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = list(map(int,input().split()))
su += k[i][0] * k[i][1]
sorted(k,key = lambda x: x[1],reverse = True)
while da... |
s196241213 | p01144 | u209989098 | 1528968429 | Python | Python3 | py | Runtime Error | 0 | 0 | 624 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = list(map(int,input().split()))
su += k[i][0] * k[i][1]
sorted(k,key = lambda x: x[1],reverse = True)
while da... |
s509375479 | p01144 | u209989098 | 1528968478 | Python | Python3 | py | Runtime Error | 0 | 0 | 622 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = map(int,input().split())
su += k[i][0] * k[i][1]
sorted(k,key = lambda x: x[1],reverse = True)
while da[1] > ... |
s285420991 | p01144 | u209989098 | 1528968580 | Python | Python3 | py | Runtime Error | 0 | 0 | 650 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = map(int,input().split())
su += k[i][0] * k[i][1]
sorted(k,key = lambda x: x[1],reverse = True)
while da[1] > ... |
s687632608 | p01144 | u209989098 | 1528968614 | Python | Python3 | py | Runtime Error | 0 | 0 | 646 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = map(int,input().split())
su += k[i][0] * k[i][1]
sorted(k,key = lambda x: x[1],reverse = True)
while da[1] > ... |
s347957582 | p01144 | u209989098 | 1528970943 | Python | Python3 | py | Runtime Error | 0 | 0 | 722 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10000)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = map(int,input().split())
su += k[i][0] * k[i][1]
k = sorted(k,key = lambda x:x[1]re... |
s009396951 | p01144 | u209989098 | 1528971073 | Python | Python3 | py | Runtime Error | 0 | 0 | 714 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10000)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = map(int,input().split())
su += k[i][0] * k[i][1]
k = sorted(k,key = lambda x:x[1]re... |
s755761812 | p01144 | u209989098 | 1528971324 | Python | Python3 | py | Runtime Error | 0 | 0 | 694 | da = list(map(int,input().split()))
k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0
while da[0] != 0 and da[1] != 0:
i = 0
su = 0
j = 0
for i in range(da[0]):
k[i][0],k[i][1] = list(map(int,input().split()))
su += k[i][0] * k[i][1]
k = sorted(k,key = lambda x: x[1],reverse = True)
w... |
s927073791 | p01145 | u967850487 | 1365513363 | Python | Python | py | Runtime Error | 0 | 0 | 2945 | #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
const string boin = "aiueo";
const string shiin = "kstnhmyrwgzdbp";
const string cho = "aiu";
const string museiinshi = "ksthp";
bool isBoin(char c) {
return boin.find(c) != string::npos;
}
bool isSh... |
s198386882 | p01146 | u352394527 | 1530796211 | Python | Python3 | py | Runtime Error | 0 | 0 | 1075 | from heapq import heappush, heappop
INF = 10 ** 20
while True:
n, m, l, k, a, h = map(int, input().split())
if n == 0:
break
if l != 0:
sisetu = list(map(int, input().split())) + [a, h]
else:
sisetu = [a, h]
costs = [[INF] * n for _ in range(n)]
for _ in range(k):
x, y, t = map(int, input... |
s367537586 | p01146 | u352394527 | 1530797633 | Python | Python3 | py | Runtime Error | 0 | 0 | 1387 | from heapq import heappush, heappop
INF = 10 ** 20
def main():
while True:
n, m, l, k, a, h = map(int, input().split())
if n == 0:
break
if l != 0:
sisetu = list(map(int, input().split())) + [a, h]
else:
input()
sisetu = [a, h]
costs = [[INF] * n for _ in range(n)]
... |
s874962060 | p01146 | u943441430 | 1555920594 | Python | Python3 | py | Runtime Error | 0 | 0 | 1708 | # AOJ2021
N = M = L = K = A = H = 0
def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
return mint
def solve2(r, t, lv):
global mint
... |
s773948158 | p01146 | u943441430 | 1555920762 | Python | Python3 | py | Runtime Error | 0 | 0 | 1708 | # AOJ2021
N = M = L = K = A = H = 0
def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
return mint
def solve2(r, t, lv):
global mint
... |
s653843468 | p01146 | u943441430 | 1555921753 | Python | Python3 | py | Runtime Error | 0 | 0 | 1741 | # AOJ2021
town = []
freezer = []
dp = []
dic = {}
mint = 100000000
N = M = L = K = A = H = 0
def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
... |
s295010015 | p01146 | u943441430 | 1555922158 | Python | Python3 | py | Runtime Error | 0 | 0 | 1715 | # AOJ2021
town = []
freezer = []
dp = []
dic = {}
mint = 100000000
def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
return mint
def solve2(... |
s460165884 | p01146 | u943441430 | 1555922189 | Python | Python3 | py | Runtime Error | 0 | 0 | 1717 | # AOJ2021
town = []
freezer = []
dp = []
dic = {}
mint = 100000000
def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
# if mint == 100000000:
# return "Help!"
return mint
def solve... |
s334491344 | p01146 | u943441430 | 1555922301 | Python | Python3 | py | Runtime Error | 0 | 0 | 1681 | # AOJ2021
town = []
freezer = []
dp = []
dic = {}
mint = 100000000
def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
return mint
def solve2(... |
s879496053 | p01146 | u943441430 | 1555922502 | Python | Python3 | py | Runtime Error | 0 | 0 | 1654 | def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
return mint
def solve2(r, t, lv):
global mint
ntown = dic[r]
for nt in ntown:
... |
s263015659 | p01146 | u943441430 | 1555922550 | Python | Python3 | py | Runtime Error | 0 | 0 | 1654 | def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
return mint
def solve2(r, t, lv):
global mint
ntown = dic[r]
for nt in ntown:
... |
s238270470 | p01146 | u943441430 | 1555922623 | Python | Python3 | py | Runtime Error | 0 | 0 | 1739 | town = []
freezer = []
dp = []
dic = {}
mint = 100000000
N = M = L = K = A = H = 0
def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
return m... |
s253447800 | p01146 | u943441430 | 1555922712 | Python | Python3 | py | Runtime Error | 0 | 0 | 1715 | town = []
freezer = []
dp = []
dic = {}
mint = 100000000
N = M = L = K = A = H = 0
def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
return m... |
s231440862 | p01146 | u943441430 | 1555922769 | Python | Python3 | py | Runtime Error | 0 | 0 | 1697 | town = []
freezer = []
dp = []
dic = {}
mint = 100000000
N = M = L = K = A = H = 0
def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
return m... |
s587839064 | p01146 | u943441430 | 1555922848 | Python | Python3 | py | Runtime Error | 0 | 0 | 1741 | town = []
freezer = []
dp = []
dic = {}
mint = 100000000
N = M = L = K = A = H = 0
def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
return m... |
s222709143 | p01146 | u943441430 | 1555923245 | Python | Python3 | py | Runtime Error | 0 | 0 | 1697 | town = []
freezer = []
dp = []
dic = {}
mint = 100000000
N = M = L = K = A = H = 0
def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
return m... |
s763283383 | p01146 | u943441430 | 1555923630 | Python | Python3 | py | Runtime Error | 0 | 0 | 1697 | town = []
freezer = []
dp = []
dic = {}
mint = 100000000
N = M = L = K = A = H = 0
def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
return m... |
s061858965 | p01146 | u943441430 | 1555923693 | Python | Python3 | py | Runtime Error | 0 | 0 | 1685 | town = []
freezer = []
dp = []
dic = {}
mint = 100000000
N = M = L = K = A = H = 0
def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
return m... |
s551060857 | p01146 | u943441430 | 1555923825 | Python | Python3 | py | Runtime Error | 0 | 0 | 1685 | town = []
freezer = []
dp = []
dic = {}
mint = 100000000
N = M = L = K = A = H = 0
def nexttown():
for r in range(0, N):
dic[r] = [t[1:3] for t in town if t[0] == r] + [ [t[0], t[2]] for t in town if t[1] == r]
def solve():
solve2(A, M, 0)
if mint == 100000000:
return "Help!"
return m... |
s599565420 | p01146 | u633068244 | 1424513295 | Python | Python | py | Runtime Error | 0 | 0 | 671 | inf = 1 << 28
def dfs(s,m,path):
global ans
if s == H:
tmp = sum(d[i][j] for i,j in zip(path,path[1:]))
ans = min(ans, tmp+max(0,tmp-M))
if s in cold: m = M
for t in range(N):
if d[s][t] <= m:
if path.count(t) > 2: continue
dfs(t,m-d[s][t],path+[t])
while... |
s176201462 | p01146 | u633068244 | 1424513731 | Python | Python | py | Runtime Error | 19930 | 4272 | 646 | inf = 1 << 28
def dfs(s,m,path):
global ans
if s == H:
tmp = sum(d[i][j] for i,j in zip(path,path[1:]))
ans = min(ans, tmp+max(0,tmp-M))
if s in cold: m = M
for t in range(N):
if d[s][t] <= m:
if path.count(t) > 1: continue
dfs(t,m-d[s][t],path+[t])
while... |
s822836342 | p01146 | u633068244 | 1424514885 | Python | Python | py | Runtime Error | 19930 | 4568 | 968 | inf = 1 << 28
while 1:
N,M,L,K,A,H = map(int,raw_input().split())
if N == 0: break
cold = map(int,raw_input().split())
d = [[inf]*N for i in xrange(N)]
for loop in xrange(K):
x,y,t = map(int,raw_input().split())
d[x][y] = d[y][x] = t
for k in xrange(N):
for i in xran... |
s592542899 | p01146 | u633068244 | 1424515001 | Python | Python | py | Runtime Error | 19920 | 4560 | 1001 | inf = 1 << 28
while 1:
N,M,L,K,A,H = map(int,raw_input().split())
if N == 0: break
cold = map(int,raw_input().split())
d = [[inf]*N for i in xrange(N)]
for loop in xrange(K):
x,y,t = map(int,raw_input().split())
d[x][y] = d[y][x] = t
for k in xrange(N):
for i in xran... |
s724938341 | p01146 | u633068244 | 1424515150 | Python | Python | py | Runtime Error | 19920 | 4572 | 1006 | inf = 1 << 28
while 1:
N,M,L,K,A,H = map(int,raw_input().split())
if N == 0: break
cold = map(int,raw_input().split())
d = [[inf]*N for i in xrange(N)]
for loop in xrange(K):
x,y,t = map(int,raw_input().split())
d[x][y] = d[y][x] = t
for k in xrange(N):
for i in xran... |
s897094406 | p01146 | u633068244 | 1424515390 | Python | Python | py | Runtime Error | 19930 | 4608 | 1105 | import copy
inf = 1 << 28
while 1:
N,M,L,K,A,H = map(int,raw_input().split())
if N == 0: break
cold = set(map(int,raw_input().split()))
d = [[inf]*N for i in xrange(N)]
for loop in xrange(K):
x,y,t = map(int,raw_input().split())
d[x][y] = d[y][x] = t
for k in xrange(N):
... |
s860130853 | p01146 | u633068244 | 1424515454 | Python | Python | py | Runtime Error | 19930 | 4608 | 1158 | import copy
inf = 1 << 28
while 1:
N,M,L,K,A,H = map(int,raw_input().split())
if N == 0: break
cold = set(map(int,raw_input().split()))
d = [[inf]*N for i in xrange(N)]
for loop in xrange(K):
x,y,t = map(int,raw_input().split())
d[x][y] = d[y][x] = t
for k in xrange(N):
... |
s368168009 | p01146 | u633068244 | 1424516410 | Python | Python | py | Runtime Error | 19920 | 4588 | 964 | def warshall(A):
n = len(A)
for k in xrange(n):
for i in xrange(n):
for j in xrange(n):
A[i][j] = min(A[i][j], A[i][k]+A[k][j])
return A
inf = 1 << 28
while 1:
N,M,L,K,A,H = map(int,raw_input().split())
if N == 0: break
cold = map(int,raw_input().split())... |
s176285013 | p01146 | u685815919 | 1474953673 | Python | Python | py | Runtime Error | 0 | 0 | 1842 | import sys
def warshall(n, matrix):
for i in xrange(n):
matrix[i][i] = 0
for i in xrange(n):
for j in xrange(n):
for k in xrange(n):
matrix[j][k] = min(matrix[j][k], matrix[j][i]+matrix[i][k])
return matrix
def dijkstra(nodes, start, matrix):
defnode = [False] * (nodes)
cost = [sys.max... |
s791034893 | p01146 | u685815919 | 1474954068 | Python | Python | py | Runtime Error | 40000 | 6700 | 1808 | import sys
def warshall(n, matrix):
for i in xrange(n):
matrix[i][i] = 0
for i in xrange(n):
for j in xrange(n):
for k in xrange(n):
matrix[j][k] = min(matrix[j][k], matrix[j][i]+matrix[i][k])
return matrix
def dijkstra(nodes, start, matrix):
defnode = [False] * (nodes)
cost = [sys.max... |
s287319238 | p01146 | u685815919 | 1479101731 | Python | Python | py | Runtime Error | 0 | 0 | 1552 | import sys
import heapq
class Dijkstra(object):
def dijkstra(self, adj, start, goal=None):
num = len(adj)
dist = [sys.maxint] * num
prev = [sys.maxint] * num
dist[start] = 0
q = []
heapq.heappush(q, (0, start))
while len(q) != 0:
prov_cost, src = heapq.heappop(q)
if dist[src]... |
s930244563 | p01146 | u260980560 | 1482831264 | Python | Python | py | Runtime Error | 0 | 0 | 969 | from heapq import heappush, heappop
while 1:
N, M, L, K, A, H = map(int, raw_input().split())
if N == 0:
break
F = [0]*N
if L>0:
for e in map(int, raw_input().split()):
F[e] = 1
G = [[] for i in xrange(N)]
for i in xrange(K):
x, y, t = map(int, raw_input().spl... |
s551504139 | p01146 | u509278866 | 1529642280 | Python | Python3 | py | Runtime Error | 0 | 0 | 2190 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdi... |
s215547005 | p01158 | u266872031 | 1422159096 | Python | Python | py | Runtime Error | 0 | 0 | 2563 | def checkloop(pdict,product,inroute):
inroute.append(product)
if pdict[product][1]==product:
return (False,product)
elif pdict[product][1] in inroute:
return (True,pdict[product][1])
else:
return checkloop(pdict,pdict[product][1],inroute)
def daysopen(pdict,product,made,notsearc... |
s385955724 | p01158 | u266872031 | 1422160510 | Python | Python | py | Runtime Error | 0 | 0 | 2604 | import sys
sys.setrecursionlimit(10000)
def checkloop(pdict,product,inroute):
inroute.append(product)
if pdict[product][1]==product:
return (False,product)
elif pdict[product][1] in inroute:
return (True,pdict[product][1])
else:
return checkloop(pdict,pdict[product][1],inroute)... |
s273585761 | p01159 | u266872031 | 1422166912 | Python | Python | py | Runtime Error | 19930 | 4288 | 691 | def f(fxp,fyp,x):
ret=0
for i in range(len(fxp)-1):
if fxp[i]<=x and fxp[i+1]>x:
ret= fyp[i]+(fyp[i+1]-fyp[i])*(x-fxp[i])/float(fxp[i+1]-fxp[i])
break
return ret
while(1):
nrinput=raw_input().split()
[n,r]=[int(nrinput[0]), float(nrinput[1])]
if n==0:
brea... |
s884652425 | p01159 | u266872031 | 1422167431 | Python | Python | py | Runtime Error | 19930 | 4292 | 690 | def f(fxp,fyp,x):
ret=0
for i in range(len(fxp)-1):
if fxp[i]<=x and fxp[i+1]>x:
ret= fyp[i]+(fyp[i+1]-fyp[i])*(x-fxp[i])/float(fxp[i+1]-fxp[i])
break
return ret
while(1):
nrinput=raw_input().split()
[n,r]=[int(nrinput[0]), float(nrinput[1])]
if n==0:
brea... |
s033066713 | p01160 | u266872031 | 1422177425 | Python | Python | py | Runtime Error | 19930 | 4252 | 930 | def trydecr(word):
longest=0
decrtemp=""
decr=""
if len(word)==0:
return ""
else:
for index in range(len(word)):
i=len(word)-1
while i>index:
if word[i]==word[index]:
decrtemp=word[index]+trydecr(word[index+1:i])+word[index]... |
s052017607 | p01160 | u266872031 | 1422177585 | Python | Python | py | Runtime Error | 0 | 0 | 1017 | import sys
sys.setrecursionlimit(10000) # 10000回 まで再帰呼び出しを許可
def trydecr(word):
longest=0
decrtemp=""
decr=""
if len(word)==0:
return ""
else:
for index in range(len(word)):
i=len(word)-1
while i>index:
if word[i]==word[index]:
... |
s871108612 | p01160 | u266872031 | 1422177764 | Python | Python | py | Runtime Error | 0 | 0 | 978 | import sys
sys.setrecursionlimit(10000)
def trydecr(word,memo):
longest=0
decrtemp=""
decr=""
if len(word)==0:
return ""
else:
for index in range(len(word)):
i=len(word)-1
while i>index:
if word[i]==word[index]:
decrtemp=... |
s734825901 | p01160 | u266872031 | 1422177832 | Python | Python | py | Runtime Error | 19930 | 4260 | 973 | import sys
sys.setrecursionlimit(10000)
def trydecr(word):
longest=0
decrtemp=""
decr=""
if len(word)==0:
return ""
else:
for index in range(len(word)):
i=len(word)-1
while i>index:
if word[i]==word[index]:
decrtemp=word[... |
s363709337 | p01171 | u772196646 | 1401854795 | Python | Python | py | Runtime Error | 0 | 0 | 574 | def prime(a):
prime = []
for p in range(2, a):
if a % p == 0:
prime.append(p)
while a % p == 0:
a /= p
return prime
def keynumber(prime):
sum = 0
for i in range(len(prime) - 1):
sum += prime[i]
key = prime[-1] - sum
return key
while 1... |
s868998353 | p01172 | u266872031 | 1428333740 | Python | Python | py | Runtime Error | 19930 | 19216 | 702 | import bisect
def index(a, x):
'Locate the leftmost value exactly equal to x'
i = bisect.bisect_left(a, x)
if i != len(a) and a[i] == x:
return i
else:
return -1
while(1):
[x,y]=[int(x) for x in raw_input().split()]
if x==0:
break
amarilist=[x]
amarilistb=[x]
... |
s253474122 | p01172 | u266872031 | 1428334929 | Python | Python | py | Runtime Error | 19930 | 5744 | 499 | while(1):
[x,y]=[int(x) for x in raw_input().split()]
digitsy=y/10+1
if x==0:
break
amarilist=[x]
amari=x
j=1
while(1):
amari=amari*10%y
if amari==0:
print len(amarilist),0
break
elif amari in amarilist:
bef=amarilist.index(... |
s701048141 | p01172 | u266872031 | 1428335257 | Python | Python | py | Runtime Error | 19930 | 4216 | 496 | while(1):
[x,y]=[int(x) for x in raw_input().split()]
digitsy=len(str(y))
if x==0:
break
amarilist=[x]
amari=x
j=1
while(1):
amari=amari*10%y
if amari==0:
print len(amarilist),0
break
elif amari in amarilist:
bef=amarilist.i... |
s166360860 | p01172 | u266872031 | 1428335479 | Python | Python | py | Runtime Error | 19930 | 4216 | 498 | while(1):
[x,y]=[int(x) for x in raw_input().split()]
digitsy=len(str(y))+1
if x==0:
break
amarilist=[x]
amari=x
j=1
while(1):
amari=amari*10%y
if amari==0:
print len(amarilist),0
break
elif amari in amarilist:
bef=amarilist... |
s699079838 | p01172 | u266872031 | 1474706201 | Python | Python | py | Runtime Error | 40000 | 8452 | 310 | #a,b
while(1):
[a,b]=[int(x) for x in raw_input().split()]
if a==0: break
Dlist=[]
while(1):
if a in Dlist:
break
Dlist.append(a)
a*=10
a%=b
if a!=0:
print Dlist.index(a),len(Dlist)-Dlist.index(a)
else:
print len(Dlist)-1,0 |
s670252044 | p01180 | u072053884 | 1520665146 | Python | Python3 | py | Runtime Error | 0 | 0 | 534 | def solve():
import sys
from itertools import combinations
input_lines = sys.stdin.readlines()
while True:
N = int(input_lines[0])
if N == 0:
break
distance = []
for t1, t2 in combinations(input_lines[1:N+1], 2):
r1, x1, y1 = map(float, t1.split())... |
s068397627 | p01192 | u266872031 | 1500258616 | Python | Python | py | Runtime Error | 40000 | 181420 | 844 | def printans(Cnum,ans):
print 'Case #'+str(Cnum)+': '+ans
Cnum=1
while(1):
inp=[int(x) for x in raw_input().split()]
if inp[0]==0: break
[n,C]=[inp[0],inp[1:]]
if C[0]!=1:
ans='Cannot pay some amount'
printans(Cnum,ans)
Cnum+=1
else:
A=[[y for y in range(55000... |
s682023953 | p01192 | u266872031 | 1500259853 | Python | Python | py | Runtime Error | 40000 | 165004 | 893 | def printans(Cnum,ans):
print 'Case #'+str(Cnum)+': '+ans
Cnum=1
while(1):
inp=[int(x) for x in raw_input().split()]
if inp[0]==0: break
[n,C]=[inp[0],inp[1:]]
Amax=C[-1]*n
if C[0]!=1:
ans='Cannot pay some amount'
printans(Cnum,ans)
Cnum+=1
else:
A=[[y for... |
s611061881 | p01193 | u078042885 | 1484929288 | Python | Python3 | py | Runtime Error | 0 | 0 | 96 | while 1:
try:f=input()[:-1]
except:break
print(eval(f) if 0<=eval(f)<10000 else 'E') |
s655991472 | p01193 | u078042885 | 1484929982 | Python | Python3 | py | Runtime Error | 0 | 0 | 99 | import sys
for l in sys.stdin:
f,_=l.split('=')
print(eval(f) if 0<=eval(f)<10000 else 'E') |
s800224021 | p01213 | u072053884 | 1529378109 | Python | Python3 | py | Runtime Error | 0 | 0 | 1211 | def lcs(x, y):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
if t:
... |
s061680675 | p01213 | u072053884 | 1529381770 | Python | Python3 | py | Runtime Error | 0 | 0 | 1347 | def lcs(x, y):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
if t:
... |
s392030623 | p01213 | u072053884 | 1529381841 | Python | Python3 | py | Runtime Error | 0 | 0 | 1308 | def lcs(x, y):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
if t:
... |
s234587652 | p01213 | u072053884 | 1529398287 | Python | Python3 | py | Runtime Error | 0 | 0 | 1280 | def lcs(x, y, pre_lcs, pre_lcs_len):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
... |
s893977302 | p01213 | u072053884 | 1529399136 | Python | Python3 | py | Runtime Error | 0 | 0 | 1312 | def lcs(x, y, pre_lcs, pre_lcs_len):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
... |
s732291044 | p01213 | u072053884 | 1529399153 | Python | Python3 | py | Runtime Error | 0 | 0 | 1272 | def lcs(x, y, pre_lcs, pre_lcs_len):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
... |
s429873139 | p01213 | u072053884 | 1529399223 | Python | Python3 | py | Runtime Error | 0 | 0 | 1311 | def lcs(x, y, pre_lcs, pre_lcs_len):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
... |
s221971991 | p01213 | u072053884 | 1529546690 | Python | Python3 | py | Runtime Error | 0 | 0 | 1195 | def lcs(x, y, pre_lcs, pre_lcs_len):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
... |
s165992796 | p01213 | u072053884 | 1529546814 | Python | Python3 | py | Runtime Error | 0 | 0 | 1201 | def lcs(x, y, pre_lcs, pre_lcs_len):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
... |
s543595610 | p01213 | u072053884 | 1529977515 | Python | Python3 | py | Runtime Error | 0 | 0 | 1311 | def lcs(x, y, pre_lcs, pre_lcs_len):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
... |
s081159110 | p01213 | u072053884 | 1530108799 | Python | Python3 | py | Runtime Error | 0 | 0 | 1311 | def lcs(x, y, pre_lcs, pre_lcs_len):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
... |
s289832196 | p01213 | u072053884 | 1530108879 | Python | Python3 | py | Runtime Error | 0 | 0 | 1255 | def lcs(x, y, pre_lcs, pre_lcs_len):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
... |
s259334342 | p01213 | u072053884 | 1530321902 | Python | Python3 | py | Runtime Error | 0 | 0 | 1311 | def lcs(x, y, pre_lcs, pre_lcs_len):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
... |
s817863484 | p01213 | u072053884 | 1530456875 | Python | Python3 | py | Runtime Error | 0 | 0 | 1311 | def lcs(x, y, pre_lcs, pre_lcs_len):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
... |
s529949886 | p01213 | u072053884 | 1530552604 | Python | Python3 | py | Runtime Error | 0 | 0 | 1311 | def lcs(x, y, pre_lcs, pre_lcs_len):
rec = []
idx = []
for c in y:
s = 0
for i, k in enumerate(idx):
t = x.find(c, s) + 1
if t < 1:
break
if t < k:
idx[i] = t
s = k
else:
t = x.find(c, s) + 1
... |
s277164022 | p01214 | u647766105 | 1389880784 | Python | Python | py | Runtime Error | 39860 | 4396 | 1579 | def toBinary(block):
return [sum(1 << i for i,bb in enumerate(b) if bb == "#") for b in block]
def toStr(bfield):
return ["".join("." if f & (1<<i) == 0 else "#" for i in xrange(W)) for f in bfield]
def rotated(block):
return map(lambda x:"".join(x),zip(*[b[:] for b in block]))[::-1]
def striped(block):
... |
s569224925 | p01223 | u546285759 | 1508274689 | Python | Python3 | py | Runtime Error | 0 | 0 | 247 | t = int(input())
for _ in range(t):
n = int(input())
h = list(map(int, input().split()))
maxv = 0, minv = 0
for i in range(len(h)-1):
maxv = max(maxv, h[i+1]-h[i])
minv = max(minv, h[i]-h[i+1])
print(maxv, minv) |
s015508564 | p01223 | u454358619 | 1378099190 | Python | Python | py | Runtime Error | 0 | 0 | 470 | import sys
def solve():
c = int(raw_input())
for i in range(c):
n = int(raw_input())
data = map(int, raw_input())
u,d = 0,0
for i in range(n - 1):
if i % 2 == 0:
if data[i + 1] - data[i] > u:
u = data[i + 1] - data[i]
e... |
s564164744 | p01225 | u772196646 | 1413772291 | Python | Python | py | Runtime Error | 19930 | 4392 | 622 | import itertools as it
T = input()
def goodset(a, b, c):
return (a == b and b == c) or (a + 1 == b and b + 1 == c)
def win(c):
return goodset(c[0], c[1], c[2]) and goodset(c[3], c[4], c[5]) and goodset(c[6], c[7], c[8])
for i in range(T):
cards = map(int, raw_input().split())
color = raw_input().spl... |
s441192594 | p01225 | u798803522 | 1469820010 | Python | Python3 | py | Runtime Error | 0 | 0 | 1247 | import os
with open("input1.txt") as f:
trial = int(f.readline())
nums,words = [],[]
for s in range(trial):
nums = [[int(n)] for n in f.readline().split(" ")]
words = [n for n in f.readline().rstrip("\n").split(" ")]
for t in range(9):
nums[t].append(words[t])
nu... |
s106830941 | p01225 | u798803522 | 1470063706 | Python | Python3 | py | Runtime Error | 0 | 0 | 1116 | trial = int(f.readline())
nums,words = [],[]
for s in range(trial):
nums = [[int(n)] for n in f.readline().split(" ")]
words = [n for n in f.readline().rstrip("\n").split(" ")]
for t in range(9):
nums[t].append(words[t])
nums = sorted(nums,key=lambda x:(x[1],x[0]),reverse=False)
n,color,cnt,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.