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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s911576273 | p00514 | u611853667 | 1374438640 | Python | Python | py | Runtime Error | 0 | 0 | 229 | def comb(a, b):
if(a < b or b < 0):return 0
if(b == 0):return 1
if(b > a - b):return comb(a, a - b)
return comb(a, b - 1) * (a - b + 1) / b
a, b, c = map(int, raw_input().split())
c -= a * b
print comb(c + a - 1, c) |
s113879747 | p00514 | u611853667 | 1374438678 | Python | Python | py | Runtime Error | 20 | 4224 | 232 | def comb(a, b):
if(a < b or b < 0):return 0
if(b == 0):return 1
if(b > a - b):return comb(a, a - b)
return comb(a, b - 1) * (a - b + 1) / b
a, b, c = map(int, raw_input().split())
c -= a * b
print comb(c + a - 1, c) |
s241323673 | p00514 | u514537648 | 1388501296 | Python | Python | py | Runtime Error | 0 | 0 | 230 | def kaijou(n):
res=1
for i in xrange(1,x+1):
res*=i
return res
def comb(a,b):
if(a<b or b<0):return 0
if(b==0):return 1
return kaijou(a)/kaijou(b)/kaijou(a-b)
a,b,c=map(int,raw_input().split())
c-=a*b
print comb(c+a-1,c) |
s272531633 | p00516 | u126478680 | 1546084898 | Python | Python3 | py | Runtime Error | 0 | 0 | 327 | # coding: utf-8
import numpy as np
N, M = list(map(int, input().split(' ')))
A = [int(input()) for _ in range(N)]
B = [int(input()) for _ in range(M)]
scores = [0 for _ in range(N)]
for j in range(M):
for i in range(N):
if A[i] <= B[j]:
scores[i] += 1
break
print(np.argmax(scores... |
s453799187 | p00516 | u811733736 | 1509451238 | Python | Python3 | py | Runtime Error | 0 | 0 | 2622 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0593
"""
import sys
from sys import stdin
from collections import namedtuple, Counter
input = stdin.readline
class RMQ(object):
INT_MAX = 2**31 - 1
def __init__(self, nn, init_val=0):
self.n = 1
while self.n... |
s668649323 | p00516 | u660774699 | 1398870789 | Python | Python | py | Runtime Error | 0 | 0 | 339 | n, m = map(int, input().split())
a = [int(input()) for i in range(n)]
b = [int(input()) for i in range(m)]
no = [114514] * 1919
for i, t in enumerate(a):
no[t] = i + 1
for i in range(1145):
no[i + 1] = min(no[i + 1], no[i])
from collections import Counter
c = Counter()
for t in b:
c[no[t]] += 1
print(c.mo... |
s482515124 | p00519 | u894114233 | 1472798104 | Python | Python | py | Runtime Error | 40000 | 1113836 | 1114 | from collections import deque
import heapq
def dijkstra(s,g,m):
color=[0]*n
dis=[float('inf')]*n
dis[s]=0
heapq.heappush(pq,[0,s])
while len(pq)!=0:
t,u=heapq.heappop(pq)
color[u]=2
if dis[u]<t:
continue
for v in g[u]:
if color[v]!=2:
... |
s206700026 | p00519 | u724548524 | 1526002307 | Python | Python3 | py | Runtime Error | 30 | 5628 | 829 | def calcm(x):
gone = [set([x])]
for _ in range(a[x][1]):
gone.append(set())
for i in gone[-2]:
for j in link[i]:
for k in gone:
if j in k:
break
else:
gone[-1].add(j)
minq = []
for... |
s202890958 | p00519 | u352394527 | 1526967080 | Python | Python3 | py | Runtime Error | 20 | 5668 | 1073 | from heapq import heappop as pop
from heapq import heappush as push
INF = 10 ** 20
n, k = map(int, input().split())
clst = []
rlst = []
for i in range(n):
c, r = map(int, input().split())
clst.append(c)
rlst.append(r)
edges = [[0] * n for i in range(n)]
for i in range(k):
a, b = map(int, input().split())
... |
s787480195 | p00521 | u121563294 | 1412267610 | Python | Python3 | py | Runtime Error | 19930 | 24688 | 1308 | from copy import deepcopy
M,N=map(int,input().split())
flag=[]
for i in range(M):
flag.append(list(input()))
fchange=deepcopy(flag)
sym=[]
for i in range(2):
sym.append(list(input()))
nmatch=0
for i in range(M-1):
for j in range(N-1):
ism=True
for k in range(2):
for l in range(2... |
s430435844 | p00522 | u352394527 | 1526895389 | Python | Python3 | py | Runtime Error | 20 | 5620 | 856 | INF = 10 ** 20
m, n = map(int, input().split())
manju_lst = [int(input()) for i in range(m)]
manju_lst.sort(reverse=True)
acc = 0
cum_sum = [0]
for manju in manju_lst:
acc += manju
cum_sum.append(acc)
clst = []
elst = []
for i in range(n):
c, e = map(int, input().split())
clst.append(c)
elst.append(e)
dp... |
s583104117 | p00523 | u296492699 | 1409246620 | Python | Python | py | Runtime Error | 0 | 0 | 344 | n=input()
for i in range(n):
a[i]=input()
tmp_out=0
for i in range(1, n-2):
b=[0,0,0]
for ii in range(i):
b[0] += a[ii]
for j in range(i+1, n-1):
for jj in range(i, j):
b[1] += a[jj]
for jj in range(j+1, n):
b[2] += a[jj]
tmp_out=max(tmp_out, min(b))... |
s989759233 | p00523 | u296492699 | 1409246733 | Python | Python | py | Runtime Error | 0 | 0 | 407 | while True:
n=input()
for i in range(n):
a[i]=input()
tmp_out=0
for i in range(1, n-2):
b=[0,0,0]
for ii in range(i):
b[0] += a[ii]
for j in range(i+1, n-1):
for jj in range(i, j):
b[1] += a[jj]
for jj in range(j+1, n):... |
s171786988 | p00523 | u296492699 | 1409246832 | Python | Python | py | Runtime Error | 0 | 0 | 416 | while True:
n=input()
a=[]
for i in range(n):
a[i]=input()
tmp_out=0
for i in range(1, n-2):
b=[0,0,0]
for ii in range(i):
b[0] += a[ii]
for j in range(i+1, n-1):
for jj in range(i, j):
b[1] += a[jj]
for jj in range... |
s743162383 | p00523 | u296492699 | 1409247995 | Python | Python | py | Runtime Error | 0 | 0 | 421 | while True:
n=input()
a=[]
for i in range(n):
a.append(input())
tmp_out=0
for i in range(1, n-2):
b=[0,0,0]
for ii in range(i):
b[0] += a[ii]
for j in range(i+1, n-1):
for jj in range(i, j):
b[1] += a[jj]
for jj in ... |
s621684027 | p00523 | u296492699 | 1409253656 | Python | Python | py | Runtime Error | 39870 | 4272 | 476 | n=input()
a=[]
for i in range(n):
a.append(input())
tmp_out=0
for i in range(n-2):
for j in range(i+1,n-1):
for k in range(j+1,n):
b=[0,0,0]
for ai in range(i,j):
b[0]+=a[ai]
for ai in range(j,k):
b[1]+=a[ai]
for ai in range... |
s140650513 | p00523 | u317901693 | 1417182850 | Python | Python | py | Runtime Error | 19930 | 8156 | 1098 | # coding: utf-8
import math as m
import cmath as c
import numbers
#ラジアンを度に変換
def rad_deg(rad):
if rad >= 0:
return m.degrees(rad)
else:
return m.degrees(2*pi-abs(rad))
input_lines = []
#f = open("input2.txt")
input_lines.append(raw_input())
N = int(input_lines[0])
pi = c.pi
#A_1〜A_Nまでインデックス付きで格納
data = {... |
s241119318 | p00523 | u317901693 | 1417200014 | Python | Python | py | Runtime Error | 0 | 0 | 1232 | # coding: utf-8
import math as m
import cmath as c
import numbers
def rad_deg(rad):
if rad >= 0:
return m.degrees(rad)
else:
return m.degrees(2*pi-abs(rad))
input_lines = []
input_lines.append(raw_input())
N = int(input_lines[0])
pi = c.pi
data = {i+1:0 for i in range(N)}
polar = {i+1:0+0j for i in range(N)}
SU... |
s369632826 | p00523 | u317901693 | 1417200069 | Python | Python | py | Runtime Error | 0 | 0 | 1223 | # coding: utf-8
import math as m
import cmath as c
import numbers
def rad_deg(rad):
if rad >= 0:
return m.degrees(rad)
else:
return m.degrees(2*pi-abs(rad))
input_lines = []
input_lines.append(raw_input())
N = int(input_lines[0])
pi = c.pi
data = {i+1:0 for i in range(N)}
polar = {i+1:0+0j for i in range(N)}
SU... |
s228669460 | p00523 | u317901693 | 1417200185 | Python | Python | py | Runtime Error | 19930 | 7468 | 1211 | # coding: utf-8
import math as m
import cmath as c
import numbers
def rad_deg(rad):
if rad >= 0:
return m.degrees(rad)
else:
return m.degrees(2*pi-abs(rad))
input_lines = []
input_lines.append(raw_input())
N = int(input_lines[0])
pi = c.pi
data = {i+1:0 for i in range(N)}
polar = {i+1:0+0j for i in range(N)}
SU... |
s411264687 | p00523 | u317901693 | 1417506545 | Python | Python | py | Runtime Error | 19930 | 7932 | 2632 | # coding: utf-8
import math as m
import cmath as c
import numbers
def rad_deg(rad):
if rad >= 0:
return m.degrees(rad)
else:
return m.degrees(2*pi-abs(rad))
input_lines = []
input_lines.append(raw_input())
N = int(input_lines[0])
pi = c.pi
data = {i+1:0 for i in range(N)}
polar = {i+1:0+0j for i in range(N)}
SU... |
s170173449 | p00523 | u317901693 | 1417542326 | Python | Python | py | Runtime Error | 19930 | 7956 | 2052 | # coding: utf-8
import math as m
import cmath as c
import numbers
def rad_deg(rad):
if rad >= 0:
return m.degrees(rad)
else:
return m.degrees(2*pi-abs(rad))
input_lines = []
input_lines.append(raw_input())
N = int(input_lines[0])
pi = c.pi
data = {i+1:0 for i in range(N)}
polar = {i+1:0+0j for i in range(N)}
SU... |
s453300070 | p00523 | u317901693 | 1417542513 | Python | Python | py | Runtime Error | 19920 | 7720 | 2056 | # coding: utf-8
import math as m
import cmath as c
import numbers
def rad_deg(rad):
if rad >= 0:
return m.degrees(rad)
else:
return m.degrees(2*pi-abs(rad))
input_lines = []
input_lines.append(raw_input())
N = int(input_lines[0])
pi = c.pi
data = {i+1:0 for i in xrange(N)}
polar = {i+1:0+0j for i in xrange(N)}
... |
s606458967 | p00523 | u567380442 | 1425199092 | Python | Python3 | py | Runtime Error | 0 | 0 | 717 | import sys
import bisect
f = sys.stdin
#n = int(f.readline())
a = list(map(int,f))
a[0] = 0
for i in range(1,len(a)):
a[i] += a[i - 1]
sum_a = a[-1]
third = sum_a // 3
ret = []
for i in range(bisect.bisect_left(a, third)):
nick1 = bisect.bisect_left(a, a[i] + third,lo=i)
for ni1 in (nick1-1,nick1)... |
s614828786 | p00523 | u266872031 | 1431440982 | Python | Python | py | Runtime Error | 19930 | 5208 | 997 | def checksmallest(edi,Clist,partS):
#rotate Alist so that sti is 0
Blist=Clist[edi:]
m=len(Blist)
BS=sum(Blist)
head=0
tail=m
body=m/2
while(head!=body and tail!=body):
left=sum(Blist[0:body])
right=sum(Blist[body:m])
#print partS,left,right
if min(right,l... |
s067349514 | p00523 | u266872031 | 1431441065 | Python | Python | py | Runtime Error | 19920 | 5184 | 1042 | def checksmallest(edi,Clist,partS):
#rotate Alist so that sti is 0
Blist=Clist[edi:]
m=len(Blist)
BS=sum(Blist)
head=0
tail=m
body=m/2
while(head!=body and tail!=body):
left=sum(Blist[0:body])
right=sum(Blist[body:m])
#print partS,left,right
if min(right,l... |
s899503543 | p00523 | u266872031 | 1431442578 | Python | Python | py | Runtime Error | 19920 | 5036 | 1097 | def checksmallest(edi,Clist,partS):
#rotate Alist so that sti is 0
Blist=Clist[edi:]
m=len(Blist)
BS=sum(Blist)
head=0
tail=m
body=m/2
while(head!=body and tail!=body):
left=sum(Blist[0:body])
right=sum(Blist[body:m])
#print partS,left,right
if min(right,l... |
s819828861 | p00523 | u266872031 | 1431443644 | Python | Python | py | Runtime Error | 19930 | 5052 | 1175 | def checksmallest(edi,Clist,partS):
#rotate Alist so that sti is 0
Blist=Clist[edi:]
m=len(Blist)
BS=sum(Blist)
head=0
tail=m
body=m/2
while(head!=body and tail!=body):
left=sum(Blist[0:body])
right=sum(Blist[body:m])
#print partS,left,right
if min(right,l... |
s369478217 | p00523 | u073685357 | 1456816081 | Python | Python | py | Runtime Error | 0 | 0 | 734 | __Author__ = 'Anomino'
# coding:UTF-8
import numpy as np
def AskUser() :
number = int(raw_input())
baum = []
for value in range(number) :
baum.append(int(raw_input()))
return baum
def CutBaum(baum, cuts) :
ideal = sum(baum) / cuts
piece_of_baum = []
tmp_baum = 0
for value in range(len(baum)) :... |
s139921075 | p00523 | u711765449 | 1484671922 | Python | Python3 | py | Runtime Error | 40000 | 7756 | 947 | n = int(input())
a = [0]*n
for i in range(n):
a[i] = int(input())
m = 0
opt = [0,0,0]
count = 0
for i in range(n-1):
for j in range(i+1,n):
for k in range(j+1,n):
g1,g2,g3 = 0,0,0
#print(i,j,k)
if i != 0:
for x in range(i+1,j):
g1 ... |
s527964559 | p00523 | u371539389 | 1491823394 | Python | Python3 | py | Runtime Error | 40000 | 8228 | 602 | from itertools import combinations
def min(a,b,c):
if a<=b and a<=c:
return a
elif b<=c:
return b
else:
return c
N=int(input())
list=[int(input())]
for i in range(1,N):
list.append(int(input())+list[-1])
a=combinations(range(0,N),3)
max_of_minimumsize=0
for i in a:
cut1... |
s476248381 | p00523 | u371539389 | 1491823842 | Python | Python3 | py | Runtime Error | 40000 | 7896 | 624 | def min(a,b,c):
if a<=b and a<=c:
return a
elif b<=c:
return b
else:
return c
N=int(input())
list=[int(input())]
for i in range(1,N):
list.append(int(input())+list[-1])
max_of_minimumsize=0
for cut1 in range(N-2):
for cut2 in range(cut1,N-1):
for cut3 in range(c... |
s622918076 | p00523 | u589276934 | 1496758941 | Python | Python3 | py | Runtime Error | 40000 | 7704 | 2717 | # coding: utf-8
numberOfLines = int(input())
cuttingPoints = [0 for _ in range(numberOfLines)]
for readLine in range(numberOfLines):
cuttingPoints[readLine] = int(input())
def selectMaxDifference(sumOfFirst, sumOfSecond, sumOfThird):
differenceBetween1And2 = abs(sumOfFirst - sumOfSecond)
differenceBetween... |
s530672876 | p00523 | u142321256 | 1503154948 | Python | Python3 | py | Runtime Error | 0 | 0 | 283 | #??\???
N = input()
A = [int(input()) for i in range(N)]
s = sum(A)#?????????????????????????????????
min_max = 0
for i in range(1,N+1):
for j in range(i+1,N+1):
for k in range(k+1,N+1):
m=min(sum(A[1:i]),sum(A[i+1:j]),sum(A)-N)
if(m>min_max):
min_max=m
print(min_max) |
s801573819 | p00523 | u334667251 | 1504168389 | Python | Python3 | py | Runtime Error | 0 | 0 | 1089 | def d(p, q):
return pos[p] - pos[q]
def solve():
p0, p1, p2 = 0, 0, 0
best = 0
fail = False
while p0 < N:
if fail:
p0 += 1
# p2????±???????
while d(p2, p1) > d(p1, p0) and p2 > p1:
p2 -= 1
fail = False
# p1????±???????
... |
s717690210 | p00523 | u901080241 | 1506485238 | Python | Python3 | py | Runtime Error | 0 | 0 | 1591 | def main():
n = int(input())
a = [int(input()) for _ in range(n)]
sm = sum(a)
tgt = sm/3
i = 0
ans = 0
llow = 0
lmid = 0
lhigh = 0
ltemp = 0
rlow = 0
rmid = 0
rhigh = 0
rtemp = 1
tempsum = 0
while rmid <= tgt:
rmid += a[rtemp]
rtemp += 1
... |
s320323584 | p00523 | u901080241 | 1506485301 | Python | Python3 | py | Runtime Error | 0 | 0 | 1364 |
n = int(input())
a = [int(input()) for _ in range(n)]
sm = sum(a)
tgt = sm/3
i = 0
ans = 0
llow = 0
lmid = 0
lhigh = 0
ltemp = 0
rlow = 0
rmid = 0
rhigh = 0
rtemp = 1
tempsum = 0
while rmid <= tgt:
rmid += a[rtemp]
rtemp += 1
rlow = rmid - a[rtemp-1]
rhigh = rmid + a[rtemp]
while lmid <= tgt:
lmid += a[... |
s616665548 | p00523 | u901080241 | 1506485510 | Python | Python3 | py | Runtime Error | 0 | 0 | 1363 | n = int(input())
a = [int(input()) for _ in range(n)]
sm = sum(a)
tgt = sm/3
i = 0
ans = 0
llow = 0
lmid = 0
lhigh = 0
ltemp = 0
rlow = 0
rmid = 0
rhigh = 0
rtemp = 1
tempsum = 0
while rmid <= tgt:
rmid += a[rtemp]
rtemp += 1
rlow = rmid - a[rtemp-1]
rhigh = rmid + a[rtemp]
while lmid <= tgt:
lmid += a[l... |
s558261687 | p00523 | u901080241 | 1506485719 | Python | Python3 | py | Runtime Error | 0 | 0 | 1364 | n = int(input())
a = [int(input()) for _ in range(n)]
sm = sum(a)
tgt = sm//3
i = 0
ans = 0
llow = 0
lmid = 0
lhigh = 0
ltemp = 0
rlow = 0
rmid = 0
rhigh = 0
rtemp = 1
tempsum = 0
while rmid <= tgt:
rmid += a[rtemp]
rtemp += 1
rlow = rmid - a[rtemp-1]
rhigh = rmid + a[rtemp]
while lmid <= tgt:
lmid += a[... |
s643673624 | p00523 | u901080241 | 1506485785 | Python | Python3 | py | Runtime Error | 0 | 0 | 1342 | n = int(input())
a = [int(input()) for _ in range(n)]
sm = sum(a)
tgt = sm//3
i = 0
ans = 0
llow = 0
lmid = 0
lhigh = 0
ltemp = 0
rlow = 0
rmid = 0
rhigh = 0
rtemp = 1
tempsum = 0
while rmid <= tgt:
rmid += a[rtemp]
rtemp += 1
rlow = rmid - a[rtemp-1]
rhigh = rmid + a[rtemp]
while lmid <= tgt:
lmid += a[... |
s645363859 | p00524 | u567380442 | 1425214034 | Python | Python3 | py | Runtime Error | 19930 | 111632 | 1332 | import sys
f = sys.stdin
n,m,x = map(int,f.readline().split())
h = [None] + [int(f.readline()) for _ in range(n)]
tuple_abt = [tuple(map(int, line.split())) for line in f]
dict_abt = {}
for ai,bi,ti in tuple_abt:
try:
if ti <= h[ai]:
dict_abt[ai][bi] = ti
except KeyError:
dict_abt... |
s606042808 | p00525 | u567380442 | 1425600922 | Python | Python3 | py | Runtime Error | 19930 | 84420 | 4235 | import math
class seg_tree:
def __init__(self, n):
self.depth = math.ceil(math.log(n, 2))
self.size = 1 << self.depth
self.bit = [0] * 2 * self.size
self.renew = [0] * 2 * self.size
def add(self, p, v):
p += self.size;
while p:
self.bit[p] += v
... |
s775378115 | p00525 | u567380442 | 1425713732 | Python | Python3 | py | Runtime Error | 0 | 0 | 4246 | import math
class seg_tree:
def __init__(self, n):
self.depth = math.ceil(math.log(n, 2))
self.size = 1 << self.depth
self.bit = [0] * 2 * self.size
self.renew = [0] * 2 * self.size
def add(self, p, v):
p += self.size;
while p:
self.bit[p] += v
... |
s723718506 | p00531 | u529013669 | 1476888989 | Python | Python3 | py | Runtime Error | 0 | 0 | 802 | # solve problem
def solve(n, m, targets, games):
counter = [0 for i in range(n+1)]
for i in range(m):
for j in range(n):
if games[i][j] == targets[i]:
counter[j+1] += 1
else:
counter[targets[i]] += 1
return counter
# main function
if __name... |
s071217397 | p00531 | u546285759 | 1503374336 | Python | Python3 | py | Runtime Error | 0 | 0 | 127 | A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())
print(min(P*A, B if C <= P else B+(P-C)*D) |
s772267706 | p00534 | u035108350 | 1440483197 | Python | Python3 | py | Runtime Error | 20 | 7848 | 739 |
def sl(dn,cn):
global f,tenkou,dist
if dn>cn or dn<0:
return False
if f[dn][cn]==-1:
a=sl(dn-1,cn-1)+dist[dn]*tenkou[cn]
b=sl(dn,cn-1)
c=min(a,b)
f[dn][cn]=c
return c
else:
return f[dn][cn]
#dn??\?????§???tenkou????????´???
def cost(dn,tenkou):... |
s117408870 | p00534 | u035108350 | 1440483216 | Python | Python3 | py | Runtime Error | 30 | 7816 | 739 |
def sl(dn,cn):
global f,tenkou,dist
if dn>cn or dn<0:
return False
if f[dn][cn]==-1:
a=sl(dn-1,cn-1)+dist[dn]*tenkou[cn]
b=sl(dn,cn-1)
c=min(a,b)
f[dn][cn]=c
return c
else:
return f[dn][cn]
#dn??\?????§???tenkou????????´???
def cost(dn,tenkou):... |
s001517890 | p00534 | u260980560 | 1512798761 | Python | Python3 | py | Runtime Error | 20 | 5720 | 347 | N, M = map(int, input().split())
D = [int(input()) for i in range(N)]
C = [int(input()) for i in range(M)]
memo = {}
def dfs(i, j):
if i == N:
return 0
if j == M:
return 10**9
if (i, j) in memo:
return memo[i, j]
memo[i, j] = res = min(dfs(i+1, j+1) + D[i]*C[j], dfs(i, j+1))
... |
s557947894 | p00534 | u889593139 | 1513936600 | Python | Python3 | py | Runtime Error | 1920 | 68932 | 422 | from copy import deepcopy
N, M = map(int, input().split(' '))
D = [int(input()) for i in range(N)]
C = [int(input()) for i in range(M)]
can_stop = N - M
memo = [[] for i in range(N + 1)]
memo[0].append(0)
memo[1].append(D[0] * C[0])
for day in range(1, M):
tmp = deepcopy(memo)
for town in range(N):
fo... |
s796546128 | p00534 | u724548524 | 1525725331 | Python | Python3 | py | Runtime Error | 100 | 5816 | 560 | n, m = map(int, input().split())
d = [int(input()) for _ in range(n)]
c = [int(input()) for _ in range(m)]
h = [[10e10 for _ in range(m)] for _ in range(n)]
q = [[0, 0, 0]]
while True:
nq = []
for i in q:
dn = i[2] + d[i[0]] * c[i[1]]
if dn < min(h[i[0]][:i[1] + 1]):
if i[0] < n - 1... |
s153281684 | p00535 | u894114233 | 1468758764 | Python | Python | py | Runtime Error | 40000 | 23220 | 859 | import copy
def check(y,x):
if 0<=y<=h-1 and 0<=x<=w-1:
return True
return False
h,w=map(int,raw_input().split())
field=[raw_input() for _ in xrange(h)]
dx=(1,1,1,0,0,-1,-1,-1)
dy=(1,0,-1,1,-1,1,0,-1)
before_field=copy.deepcopy(field)
ans=-1
while 1:
ans+=1
cnt=[[0]*w for _ in xrange(h)]
f... |
s786968461 | p00535 | u260980560 | 1512799810 | Python | Python3 | py | Runtime Error | 8000 | 5608 | 750 | H, W = map(int, input().split())
S = []
for i in range(H):
tmp = []
s = input()
for j in range(W):
if s[j] == '.':
tmp.append(-1)
else:
tmp.append(int(s[j]))
S.append(tmp)
D = [0, 1, -1, -1, 0, -1, 1, 1, 0]
update = 1; ans = 0
while update:
update = 0; ans += ... |
s178510081 | p00535 | u724548524 | 1525727754 | Python | Python3 | py | Runtime Error | 8140 | 5792 | 768 | h, w = map(int, input().split())
a = []
c = set()
def check(c):
global a
s = sum(a[c[0] + i][c[1] + j] == 0 for i in range(-1, 2) for j in range(-1, 2))
if s >= a[c[0]][c[1]]:
return True
else:
return False
for _ in range(h):
a.append(list(input()))
for i in range(h):
... |
s205744253 | p00536 | u886119481 | 1509861199 | Python | Python3 | py | Runtime Error | 40000 | 7744 | 1867 | #Some of grobal args
COMMANDS = ["Anna", "trush", "Bruno"]
MARKETSUM = 0
answer = 0
#List for rare, market value
tre_list = []
class Thieves():
#This holds two thieves market and rare value.
def __init__(self, parent=None):
if parent is None:
self.Anna = [0, 0]
self.Bruno = [0,... |
s916421896 | p00537 | u894114233 | 1472129432 | Python | Python | py | Runtime Error | 40000 | 30784 | 460 | n,m=map(int,raw_input().split())
p=map(int,raw_input().split())
abc=[map(int,raw_input().split()) for _ in xrange(n-1)]
cnt=[0]*(n-1)
for i in xrange(m-1):
p[i]-=1
p[i+1]-=1
if p[i]<p[i+1]:
for j in xrange(p[i],p[i+1]):
cnt[j]+=1
else:
for j in xrange(p[i],p[i+1],-1):
... |
s904768495 | p00538 | u352394527 | 1524206907 | Python | Python3 | py | Runtime Error | 670 | 18956 | 556 | n = int(input())
A = [int(input()) for i in range(n)] * 2
dp = [[-1 for i in range(n * 2)] for j in range(n * 2)]
def dfs(i,j):
#if (j - i > n - 1):undefined
if dp[i][j] != -1:
pass
elif (j - i == n - 1):
dp[i][j] = 0
elif (j - i) % 2 == 0:
if A[i - 1] > A[j + 1]:
dp[i][j] = dfs(i - 1, j)
... |
s703311315 | p00538 | u352394527 | 1524206968 | Python | Python3 | py | Runtime Error | 390 | 18964 | 527 | n = int(input())
A = [int(input()) for i in range(n)] * 3
dp = [[-1 for i in range(n * 2)] for j in range(n * 2)]
def dfs(i,j):
#if (j - i > n - 1):undefined
if dp[i][j] != -1:
pass
elif (j - i == n - 1):
dp[i][j] = 0
elif (j - i) % 2 == 0:
if A[i - 1] > A[j + 1]:
dp[i][j] = dfs(i - 1, j)
... |
s058067938 | p00539 | u894114233 | 1472802199 | Python | Python | py | Runtime Error | 30 | 6964 | 1063 | from collections import deque
import heapq
def dijkstra(s,g,m):
color=[0]*n
dis={}
for i in xrange(n):
dis[i]=float('inf')
dis[s]=0
heapq.heappush(pq,[0,s])
while len(pq)!=0:
t,u=heapq.heappop(pq)
color[u]=2
if dis[u]<t:
continue
for v in g[u]... |
s517926167 | p00539 | u894114233 | 1472803110 | Python | Python | py | Runtime Error | 0 | 0 | 972 | from collections import deque
import heapq
def dijkstra(s,g):
color=[0]*n
dis={}
for i in xrange(n):
dis[i]=float('inf')
dis[s]=0
heapq.heappush(pq,[0,s])
while len(pq)!=0:
t,u=heapq.heappop(pq)
color[u]=2
if dis[u]<t:
continue
for v,c in g[u]... |
s858231869 | p00542 | u452212317 | 1494813837 | Python | Python3 | py | Runtime Error | 0 | 0 | 166 | a,b,c,d,e,f = map(int, input().split())
x = a + b + c + d + e + f
y = 100000
for i in (a,b,c,d):
if y > i : y = i
z = 0
if e < f : z = f
else z = e
print (x - y - z) |
s246063356 | p00542 | u452212317 | 1494813909 | Python | Python3 | py | Runtime Error | 0 | 0 | 168 | a,b,c,d,e,f = map(int, input().split())
x = a + b + c + d + e + f
y = 100000
for i in (a,b,c,d):
if y > i : y = i
z = 0
if e < f : z = f
else : z = e
print (x - y - z) |
s057869772 | p00542 | u889593139 | 1522029746 | Python | Python3 | py | Runtime Error | 0 | 0 | 107 | points = []
for _ in range(6):
points.append(int(input())
print(sum(sorted(points, reverse=True)[:3]))
|
s590733105 | p00542 | u889593139 | 1522029787 | Python | Python3 | py | Runtime Error | 0 | 0 | 107 | points = []
for i in range(6):
points.append(int(input())
print(sum(sorted(points, reverse=True)[:3]))
|
s954839582 | p00543 | u221679506 | 1467997365 | Python | Python3 | py | Runtime Error | 0 | 0 | 261 | n,k = map(int,input().split())
d={}
for i in range(n):
d[i+1] = int(input())
for i in range(n):
j = i+1
if j == n:
break
if d[i]%k > d[i+1]%k:
t = d[i]
d[i] = d[i+1]
d[i+1] = t
for i in range(n):
print(d[i+1]) |
s393203057 | p00545 | u724548524 | 1525719694 | Python | Python3 | py | Runtime Error | 0 | 0 | 523 | n, t, q = map(int, input().split())
x = [[0, 0, 0] for _ in range(n)]
s = -10e10
for i in range(n):
x[i] = list(map(long, input().split())) + [0]
x[i][2] = x[i][0] + (1 if x[i][1] == 1 else -1) * t
if x[i - 1][1] == 1 and x[i][1] == 2:
s = int((x[i - 1][0] + x[i][0]) / 2)
j = 1
while... |
s282258934 | p00550 | u894114233 | 1490594770 | Python | Python | py | Runtime Error | 2590 | 101236 | 1768 | from copy import deepcopy
from collections import deque
n,m,q=map(int,raw_input().split())
e=[]
g1=[[] for _ in xrange(n)]
for i in xrange(m):
u,v=map(int,raw_input().split())
u-=1;v-=1
g1[u].append(v)
g1[v].append(u)
e.append((u,v))
d1=[10**9]*n
d1[0]=0
dq=deque([0])
while len(dq)>0:
now=dq.po... |
s061943091 | p00550 | u894114233 | 1490594863 | Python | Python | py | Runtime Error | 2620 | 106628 | 1828 | from copy import deepcopy
from collections import deque
from sys import setrecursionlimit
n,m,q=map(int,raw_input().split())
e=[]
g1=[[] for _ in xrange(n)]
for i in xrange(m):
u,v=map(int,raw_input().split())
u-=1;v-=1
g1[u].append(v)
g1[v].append(u)
e.append((u,v))
d1=[10**9]*n
d1[0]=0
dq=deque(... |
s082223817 | p00551 | u150984829 | 1517065084 | Python | Python3 | py | Runtime Error | 0 | 0 | 327 | k=int(input().split()[1])
p=input()
x=y=d=e=f=g=0
a=[(0,0)]
for _ in[0]*k:
for s in p:
if'E'==s:x+=1;g=[g,x][g<x]
if'N'==s:y+=1;e=[e,y][e<y]
if'W'==s:x-=1;f=[f,x][f>x]
if'S'==s:y-=1;d=[d,y][d>y]
a+=[(x,y)]
print(sum([1 for y in range(d,e)for x in range(f,g)if all((x,y)in a,(x+1,y)in a,(x,y+1)in a,(x+1,y+1)in... |
s810431221 | p00551 | u150984829 | 1517065318 | Python | Python3 | py | Runtime Error | 0 | 0 | 329 | k=int(input().split()[1])
p=input()
x=y=d=e=f=g=0
a=[(0,0)]
for _ in[0]*k:
for s in p:
if'E'==s:x+=1;g=[g,x][g<x]
if'N'==s:y+=1;e=[e,y][e<y]
if'W'==s:x-=1;f=[f,x][f>x]
if'S'==s:y-=1;d=[d,y][d>y]
a+=[(x,y)]
s=set(a)
print(sum([1 for y in range(d,e)for x in range(f,g)if not set([(x,y),(x+1,y),(x,y+1),(x+1,y+1)... |
s868917735 | p00551 | u150984829 | 1517065336 | Python | Python3 | py | Runtime Error | 0 | 0 | 328 | k=int(input().split()[1])
p=input()
x=y=d=e=f=g=0
a=[(0,0)]
for _ in[0]*k:
for s in p:
if'E'==s:x+=1;g=[g,x][g<x]
if'N'==s:y+=1;e=[e,y][e<y]
if'W'==s:x-=1;f=[f,x][f>x]
if'S'==s:y-=1;d=[d,y][d>y]
a+=[(x,y)]
s=set(a)
print(sum([1 for y in range(d,e)for x in range(f,g)if not set([(x,y),(x+1,y),(x,y+1),(x+1,y+1)... |
s540569740 | p00551 | u150984829 | 1517066978 | Python | Python3 | py | Runtime Error | 0 | 0 | 478 | import collections
k=int(input().split()[1])-1
p=input()
x=y=d=e=f=g=0
a=collections.deque([(0,0)])
for s in p:
if'E'==s:x+=1;g=[g,x][g<x]
if'N'==s:y+=1;e=[e,y][e<y]
if'W'==s:x-=1;f=[f,x][f>x]
if'S'==s:y-=1;d=[d,y][d>y]
a.append((x,y))
g+=x*k if x>0 else f+=x*k
if y>0:e+=y*k
else:d+=y*k
for t in set(a):
for i in ... |
s132550386 | p00551 | u150984829 | 1517394412 | Python | Python3 | py | Runtime Error | 0 | 0 | 239 | k=int(input().split()[1])
p=input()
x=y=0
a=[(0,0)]
for _ in[0]*k:
for s in p:
if'E'==s:x+=1
if'N'==s:y+=1
if'W'==s:x-=1
if'S'==s:y-=1
a+=[(x,y)]
s=set(a)
print(sum([1 for x,y in a if set([(x,y),(x+1,y),(x,y+1),(x+1,y+1)])<a]))
|
s800673838 | p00551 | u150984829 | 1517394628 | Python | Python3 | py | Runtime Error | 230 | 20112 | 236 | k=int(input().split()[1])
x=y=0
a=set([(0,0)])
for _ in[0]*k:
for s in input():
if'E'==s:x+=1
if'N'==s:y+=1
if'W'==s:x-=1
if'S'==s:y-=1
a|=set([(x,y)])
print(sum([1 for x,y in a if set([(x,y),(x+1,y),(x,y+1),(x+1,y+1)])<a]))
|
s113414027 | p00551 | u150984829 | 1517394962 | Python | Python3 | py | Runtime Error | 0 | 0 | 329 | from multiprocessing import *
k=int(input().split()[1])
p=input()
x=y=0
a=[(0,0)]
for _ in[0]*k:
for s in p:
if'E'==s:x+=1
if'N'==s:y+=1
if'W'==s:x-=1
if'S'==s:y-=1
a+=[(x,y)]
a=set(a)
with Pool(9)as p:
for s in p.map(q,range(1,k+1)):a|=set(s)
print(sum([1 for x,y in a if set([(x,y),(x+1,y),(x,y+1),(x+1,y+1... |
s985111240 | p00551 | u150984829 | 1517395760 | Python | Python3 | py | Runtime Error | 270 | 20108 | 275 | k=int(input().split()[1])
p=input()
x=y=0
a=set([(0,0)])
for s in p:
if'E'==s:x+=1
if'N'==s:y+=1
if'W'==s:x-=1
if'S'==s:y-=1
a|=set([(x,y)])
for u,v in a:a|=set([(u+x*i,v+y*i)for i in range(1,k)])
print(sum([1 for x,y in a if set([(x,y),(x+1,y),(x,y+1),(x+1,y+1)])<a]))
|
s431036261 | p00551 | u150984829 | 1517398921 | Python | Python3 | py | Runtime Error | 0 | 0 | 241 | k=int(input().split()[1])
x=y=0
a={(0,0)}
for s in input():
if'E'==s:x+=1
if'N'==s:y+=1
if'W'==s:x-=1
if'S'==s:y-=1
a|=[(x,y)]
a={(u+x*i,v+y*i)for u,v in a for i in range(k)}
print(sum({(x,y),(x+1,y),(x,y+1),(x+1,y+1)}<a for x,y in a))
|
s610828919 | p00551 | u150984829 | 1517399093 | Python | Python3 | py | Runtime Error | 0 | 0 | 242 | k=int(input().split()[1])
x=y=0
a={(0,0)}
for s in input():
if'E'==s:x+=1
elif'N'==s:y+=1
elif'W'==s:x-=1
elses:y-=1
a|={(x,y)}
a={(u+x*i,v+y*i)for u,v in a for i in range(k)}
print(sum({(x,y),(x+1,y),(x,y+1),(x+1,y+1)}<a for x,y in a))
|
s081691355 | p00553 | u814278309 | 1559284881 | Python | Python3 | py | Runtime Error | 0 | 0 | 183 | for i in range(5):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if a<0:
x=abs(a)*c+d+b*e
print(x)
else:
y=(b-a)*e
print(y)
|
s657139622 | p00553 | u814278309 | 1559285040 | Python | Python3 | py | Runtime Error | 0 | 0 | 205 | for i in range(5):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if a<0:
x=abs(a)*c+d+b*e
print(x)
elif a>=0:
y=(b-a)*e
print(y)
else:
pass
|
s483342501 | p00553 | u814278309 | 1559382040 | Python | Python3 | py | Runtime Error | 0 | 0 | 183 | for i in range(5):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if a<0:
x=abs(a)*c+d+b*e
print(x)
else:
y=(b-a)*e
print(y)
|
s787780051 | p00553 | u814278309 | 1559382492 | Python | Python3 | py | Runtime Error | 0 | 0 | 220 | for i in range(5):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if a<0 and a<b:
x=abs(a)*c+d+b*e
print(x)
elif a>0 and a<b:
y=(b-a)*e
print(y)
else:
pass
|
s945909442 | p00553 | u814278309 | 1559382767 | Python | Python3 | py | Runtime Error | 0 | 0 | 221 | for i in range(5):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if a<0 and a<b:
x=abs(a)*c+d+b*e
print(x)
elif a>0 and a<b:
y=(b-a)*e
print(y)
else:
break
|
s927570878 | p00553 | u584110575 | 1484021416 | Python | Python3 | py | Runtime Error | 0 | 0 | 168 | a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
>>> import time
>>> time.sleep(1)
if(a>=0):
print ((b-a)*e);
else:
print(a*-c+d+b*e); |
s519429963 | p00553 | u220324665 | 1484391624 | Python | Python3 | py | Runtime Error | 40000 | 7416 | 149 | import time
s=time.time()
while time.time()-s<39.99:pass
i=input;a,b,c,d,e=map(int,[i(),i(),i(),i(),i()])
print(c*-a+d+b*e)if a<0 else print((b-a)*e) |
s311123586 | p00553 | u220324665 | 1484391845 | Python | Python3 | py | Runtime Error | 40000 | 7264 | 149 | import time
s=time.time()
while time.time()-s<39.99:pass
i=input;a,b,c,d,e=map(int,[i(),i(),i(),i(),i()])
print(c*-a+d+b*e)if a<0 else print((b-a)*e) |
s159956843 | p00553 | u220324665 | 1484391966 | Python | Python3 | py | Runtime Error | 40000 | 7420 | 149 | import time
s=time.time()
while time.time()-s<39.99:pass
i=input
a,b,c,d,e=map(int,[i(),i(),i(),i(),i()])
print(c*-a+d+b*e)if a<0 else print((b-a)*e) |
s079592596 | p00553 | u220324665 | 1484392084 | Python | Python3 | py | Runtime Error | 40000 | 7356 | 150 | import time
s=time.time()
while time.time()-s<39.99:pass
i=input;a,b,c,d,e=map(int,[i(),i(),i(),i(),i()])
if a<0:print(c*-a+d+b*e)
else:print((b-a)*e) |
s642100078 | p00553 | u220324665 | 1484392187 | Python | Python3 | py | Runtime Error | 40000 | 7336 | 150 | import time
s=time.time()
while time.time()-s<39.99:pass
i=input
a,b,c,d,e=map(int,[i(),i(),i(),i(),i()])
if a<0:print(c*-a+d+b*e)
else:print((b-a)*e) |
s698498716 | p00553 | u503263570 | 1501160730 | Python | Python3 | py | Runtime Error | 0 | 0 | 351 | A=?????¨?????¨??????????????? = int(input())
B=??????????????? = int(input())
C=?????£????????????????????????????????????????????? = int(input())
D=?????£??????????§£?????????????????????????????? = int(input())
E=?????£?????????????????????????????????????????????????????? = int(input())
if A>0:
print((B-A)*E)
else... |
s893833079 | p00556 | u352394527 | 1531233486 | Python | Python3 | py | Runtime Error | 13760 | 115236 | 612 | INF = 10 ** 20
def minimum_cost(rest, init, dic):
if rest in dic:
return dic[rest]
if rest == ():
return 0
ret = INF
for nex in rest:
nex_init = init + acc[nex]
ret = min(ret, minimum_cost(tuple(i for i in rest if i != nex), nex_init, dic) +\
acc[nex] - (cums[nex][nex_init] ... |
s689681787 | p00556 | u352394527 | 1531234122 | Python | Python3 | py | Runtime Error | 9790 | 108596 | 757 | def main():
INF = 10 ** 20
def minimum_cost(rest, init, dic):
if rest in dic:
return dic[rest]
if rest == ():
return 0
ret = INF
for nex in rest:
accnex = acc[nex]
cumsnex = cums[nex]
nex_init = init + accnex
tmp = minimum_cost(tuple([i for i in rest if i !... |
s334471858 | p00556 | u450407555 | 1485517743 | Python | Python | py | Runtime Error | 40000 | 135000 | 634 | import sys
n, m = map(int, raw_input().split())
cnt = [0 for _ in range(n)]
cntS = [[0 for _ in range(n)] for _ in range(m)]
for i in range(n):
k = input()-1
cnt[k] += 1
cntS[k][i] = 1
for k in range(m):
for i in range(n-1):
cntS[k][i+1] += cntS[k][i]
dp = [sys.maxint/4 for _ in range(1<<m)]
dp[0] = 0
... |
s824360433 | p00556 | u260980560 | 1512764354 | Python | Python3 | py | Runtime Error | 18420 | 59844 | 736 | N, M = map(int, input().split())
N2 = 2**N.bit_length()
D = [[0]*(N2+1) for i in range(M)]
def get(i, k):
data = D[i]
s = 0
while k:
s += data[k]
k -= k & -k
return s
def add(i, k, x):
data = D[i]
while k <= N2:
data[k] += x
k += k & -k
cnts = [0]*M
for i in range... |
s122388488 | p00565 | u881891940 | 1530105750 | Python | Python3 | py | Runtime Error | 0 | 0 | 132 | n = int(input())
a = list(map(int,input()(split()))
for i in range(1,n):
if a[i] > 0:
a[i] += a[i-1]
print(max(a[i])+1)
|
s141343012 | p00565 | u881891940 | 1530105847 | Python | Python3 | py | Runtime Error | 0 | 0 | 131 | n = int(input())
a = list(map(int,input().split())
for i in range(1,n):
if a[i] > 0:
a[i] += a[i-1]
print(max(a[i])+1)
|
s154122236 | p00570 | u363745648 | 1530284290 | Python | Python3 | py | Runtime Error | 0 | 0 | 1037 | n,k = map(int,input().split())
numbers = []
times = []
for i in range(n):
numbers.append(i)
times.append(int(input()))
candidates = [ [0] + x for x in gen_kcombination(numbers[1:],k-1)]
bestTime = times[-1] + 1
for i in range(len(candidates)):
candidate = candidates[i]
time = 0
for j in range(k-1):
ig... |
s618003503 | p00570 | u363745648 | 1530284395 | Python | Python3 | py | Runtime Error | 0 | 0 | 1037 | n,k = map(int,input().split())
numbers = []
times = []
for i in range(n):
numbers.append(i)
times.append(int(input()))
candidates = [ [0] + x for x in gen_kcombination(numbers[1:],k-1)]
bestTime = times[-1] + 1
for i in range(len(candidates)):
candidate = candidates[i]
time = 0
for j in range(k-1):
ig... |
s823908106 | p00570 | u363745648 | 1530284800 | Python | Python3 | py | Runtime Error | 20 | 5616 | 1036 | def gen_kcombination(lis,k):
if k >= len(lis):
return [lis]
kcombs = []
if k == 1:
return [[x] for x in lis]
for i in range(len(lis... |
s922677830 | p00574 | u002193969 | 1522546708 | Python | Python3 | py | Runtime Error | 0 | 0 | 740 | L, Q = [int(x) for x in input().split()]
poison = [int(x) for x in list(input())]
i = 0
while i < Q:
ans = 0
snakelist = []
newsnakelist = []
snakelist.append(input())
for x in range(0,L):
for snake in snakelist:
if snake[x] == "?":
a = snake[:x] + "0" + snake[x+1... |
s177393492 | p00574 | u002193969 | 1522546786 | Python | Python3 | py | Runtime Error | 0 | 0 | 719 | L, Q = [int(x) for x in input().split()]
poison = [int(x) for x in list(input())]
i = 0
while i < Q:
ans = 0
snakelist = []
newsnakelist = []
snakelist.append(input())
for x in range(0,L):
for snake in snakelist:
if snake[x] == "?":
a = snake[:x] + "0" + snake[x+1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.