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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s336877881 | p00467 | u889593139 | 1521683910 | Python | Python3 | py | Runtime Error | 0 | 0 | 402 | while True:
N, M = map(int, input().split())
if N == 0:
break
mapp = [int(input()) for _ in range(N)]
mas = 0
ans = 0
for dice in range(M):
mas += int(input())
if mas >= n - 1 and ans == 0:
ans = dice + 1
if mas < n - 1:
lmas += mapp[ans]
... |
s295044733 | p00467 | u889593139 | 1521683953 | Python | Python3 | py | Runtime Error | 0 | 0 | 401 | while True:
N, M = map(int, input().split())
if N == 0:
break
maps = [int(input()) for _ in range(N)]
mas = 0
ans = 0
for dice in range(M):
mas += int(input())
if mas >= n - 1 and ans == 0:
ans = dice + 1
if mas < n - 1:
mas += maps[ans]
... |
s011631144 | p00467 | u150984829 | 1526187315 | Python | Python3 | py | Runtime Error | 0 | 0 | 202 | for e in iter(input,'0 0'):
N,M=map(int,e.split())
S=[int(input())for _ in[0]*N]
print(S)
p=b=1
for i in range(M):
d=int(input())
p+=d
p+=S[~-p]
print('pos', p)
if(N<=p)*b:print(-~i);b=0
|
s944684798 | p00467 | u150984829 | 1526187326 | Python | Python3 | py | Runtime Error | 0 | 0 | 184 | for e in iter(input,'0 0'):
N,M=map(int,e.split())
S=[int(input())for _ in[0]*N]
print(S)
p=b=1
for i in range(M):
d=int(input())
p+=d
p+=S[~-p]
if(N<=p)*b:print(-~i);b=0
|
s985961919 | p00467 | u150984829 | 1526187369 | Python | Python3 | py | Runtime Error | 0 | 0 | 174 | for e in iter(input,'0 0'):
N,M=map(int,e.split())
S=[int(input())for _ in[0]*N]
p=b=1
for i in range(M):
d=int(input())
p+=d
p+=S[~-p]
if(N<=p)*b:print(-~i);b=0
|
s068721091 | p00467 | u150984829 | 1526187885 | Python | Python3 | py | Runtime Error | 0 | 0 | 195 | for e in iter(input,'0 0'):
N,M=map(int,e.split())
k=p=1
S=[int(input()) for _ in[0]*N]
for d in[int(input())for _ in[0]*M]:
p+=n if n-1<=p+i else i+S[p+i]
if n<=p:break
k+=1
print(k)
|
s978964313 | p00467 | u150984829 | 1526188276 | Python | Python3 | py | Runtime Error | 0 | 0 | 196 | for e in iter(input,'0 0'):
N,M=map(int,e.split())
k,p=1,0
S=[int(input()) for _ in[0]*N]
for d in[int(input())for _ in[0]*M]:
p+=d if N<p+d else d+S[p+d]
if N<=p+1:break
k+=1
print(k)
|
s361236576 | p00467 | u150984829 | 1526188687 | Python | Python3 | py | Runtime Error | 0 | 0 | 266 | import sys
r=sys.stdin.readline
def s():
for e in iter(r,'0 0'):
N,M=map(int,e.split())
k,p=1,0
S=[int(r()) for _ in[0]*N]
for d in[int(r())for _ in[0]*M]:
p+=d if N<=p+d else d+S[p+d]
if N<=p+1:break
k+=1
print(k)
if'__main__'==__name__:solve()
|
s845199903 | p00467 | u150984829 | 1526188701 | Python | Python3 | py | Runtime Error | 0 | 0 | 262 | import sys
r=sys.stdin.readline
def s():
for e in iter(r,'0 0'):
N,M=map(int,e.split())
k,p=1,0
S=[int(r()) for _ in[0]*N]
for d in[int(r())for _ in[0]*M]:
p+=d if N<=p+d else d+S[p+d]
if N<=p+1:break
k+=1
print(k)
if'__main__'==__name__:s()
|
s488027919 | p00467 | u150984829 | 1526188779 | Python | Python3 | py | Runtime Error | 0 | 0 | 264 | def s():
import sys
r=sys.stdin.readline
for e in iter(r,'0 0'):
N,M=map(int,e.split())
k,p=1,0
S=[int(r()) for _ in[0]*N]
for d in[int(r())for _ in[0]*M]:
p+=d if N<=p+d else d+S[p+d]
if N<=p+1:break
k+=1
print(k)
if'__main__'==__name__:s()
|
s022114148 | p00467 | u150984829 | 1526189157 | Python | Python3 | py | Runtime Error | 0 | 0 | 214 | import sys
r=sys.stdin.readline
for e in iter(r,'0 0\n'):
N,M=map(int,e.split())
k,p=1,0
S=[int(r()) for _ in[0]*N]
for d in[int(r())for _ in[0]*M]:
p+=d;
if N<=p:p+=S[p]
if N<=p+1:break
k+=1
print(k)
|
s506539798 | p00467 | u621997536 | 1384424492 | Python | Python | py | Runtime Error | 0 | 0 | 317 | mass = [0] * 1000
num = [0] * 1000
while True:
N, M = map(int, raw_input().split())
if N == 0 and M == 0:
break
p = 0
for i in range(N):
mass[i] = input()
for i in range(M):
num[i] = input()
for i in range(M):
p += num[i];
p += mass[p]
if p >= N - 1:
print i + 1
break |
s491459033 | p00467 | u260980560 | 1397474879 | Python | Python | py | Runtime Error | 0 | 0 | 310 | while True:
n, m = map(int, raw_input().split())
if n==0 and m==0:
break
b = [input() for i in xrange(n)]
p = 0; ans = 0;
for i in xrange(m):
d = input()
p += d
if p>=n-1 or p+b[p]>=n-1:
ans = i+1
break
p += b[p]
print ans |
s869343561 | p00468 | u724963150 | 1507199114 | Python | Python3 | py | Runtime Error | 0 | 0 | 403 | while True:
n=int(input())
if n==0:break
m=int(input())
rel=sorted([[int(s)for s in input().split(" ")]for i in range(m)],key=lambda x:x[0])
isf=[False for i in range(n)]
inv=[False for i in range(n)]
isf[0]=True
for r in rel:
if r[0]==1:
isf[r[1]]=True
in... |
s742444896 | p00468 | u150984829 | 1526191342 | Python | Python3 | py | Runtime Error | 0 | 0 | 208 | import sys
r=sys.stdin.readline
for e in iter(r,'0'):
R=[[]for _ in[0]*-~int(e)]
for _ in[0]*int(r()):
a,b=map(int,r().split())
R[a]+=[b];R[b]+=[a]
for m in R[1][:]:R[1]+=R[m]
print(len({*R[1]}-{1}))
|
s090396055 | p00468 | u460331583 | 1347008862 | Python | Python | py | Runtime Error | 0 | 1544 | 402 | while True:
fri = int(input())
count = int(input())
if fri == 0 and count ==0: break
a,b,c,d = [],[],[],[]
for i in range(count):
t = map(int,raw_input().split())
if t[0] == 1:
if not(t[1] in b):
b.append(t[1])
continue
if t[0] in b:
if not(t[1] in b):
c.append... |
s417929578 | p00468 | u104911888 | 1368797798 | Python | Python | py | Runtime Error | 0 | 0 | 362 | while True:
n,m=input(),input()
if n==m==0:break
S,L=set(),[]
for i in range(m):
a,b=map(int,raw_input().split())
if a==1:
S.add(b)
elif b==1:
S.add(a)
else:
L.append((a,b))
for i in S:
for s in L:
if i in s:
... |
s982235680 | p00468 | u104911888 | 1368797850 | Python | Python | py | Runtime Error | 0 | 0 | 366 | while True:
n=input()
m=input()
if n==m==0:break
S,L=set(),[]
for i in range(m):
a,b=map(int,raw_input().split())
if a==1:
S.add(b)
elif b==1:
S.add(a)
else:
L.append((a,b))
for i in S:
for s in L:
if i in s:... |
s433924265 | p00468 | u104911888 | 1368797916 | Python | Python | py | Runtime Error | 0 | 0 | 420 | while True:
try:
n=input()
m=input()
except SyntaxError:
pass
if n==m==0:break
S,L=set(),[]
for i in range(m):
a,b=map(int,raw_input().split())
if a==1:
S.add(b)
elif b==1:
S.add(a)
else:
L.append((a,b))
... |
s516596459 | p00468 | u104911888 | 1368797985 | Python | Python | py | Runtime Error | 0 | 0 | 375 | while True:
n,m=map(int,raw_input().split())
if n==m==0:break
S,L=set(),[]
for i in range(m):
a,b=map(int,raw_input().split())
if a==1:
S.add(b)
elif b==1:
S.add(a)
else:
L.append((a,b))
for i in S:
for s in L:
i... |
s467536185 | p00468 | u104911888 | 1368798030 | Python | Python | py | Runtime Error | 0 | 0 | 384 | while True:
n=int(raw_input())
m=int(raw_input())
if n==m==0:break
S,L=set(),[]
for i in range(m):
a,b=map(int,raw_input().split())
if a==1:
S.add(b)
elif b==1:
S.add(a)
else:
L.append((a,b))
for i in S:
for s in L:
... |
s021741665 | p00468 | u104911888 | 1368798817 | Python | Python | py | Runtime Error | 0 | 0 | 363 | while True:
n=input()
m=input()
if n==0:break
S,L=set(),[]
for i in range(m):
a,b=map(int,raw_input().split())
if a==1:
S.add(b)
elif b==1:
S.add(a)
else:
L.append((a,b))
for i in S:
for s in L:
if i in s:
... |
s850038616 | p00468 | u104911888 | 1368798908 | Python | Python | py | Runtime Error | 0 | 0 | 371 | while True:
n=raw_input()
m=input()
if n in "0":break
S,L=set(),[]
for i in range(m):
a,b=map(int,raw_input().split())
if a==1:
S.add(b)
elif b==1:
S.add(a)
else:
L.append((a,b))
for i in S:
for s in L:
if i ... |
s112907486 | p00468 | u104911888 | 1368798940 | Python | Python | py | Runtime Error | 0 | 0 | 371 | while True:
n=raw_input()
if n in "0":break
m=input()
S,L=set(),[]
for i in range(m):
a,b=map(int,raw_input().split())
if a==1:
S.add(b)
elif b==1:
S.add(a)
else:
L.append((a,b))
for i in S:
for s in L:
if i ... |
s697823074 | p00468 | u621997536 | 1384425839 | Python | Python | py | Runtime Error | 0 | 0 | 574 | l = []
t = []
ans = [False] * 500
while True:
l = []
t = []
ans = [False] * 500
N = input()
M = input()
if N == 0 and M == 0:
break
for i in range(M):
a, b = map(int, raw_input().split())
l.append([a, b])
if a == 1:
t.append(b)
if b == 1:
t.append(a)
for i in t:
ans[i... |
s841077819 | p00469 | u150984829 | 1526193473 | Python | Python3 | py | Runtime Error | 0 | 0 | 181 | from itertools import permutations as P
import sys
r=sys.stdin.readline
for e in iter(r,'0'):
n,k=int(e),int(r())
C=[r()for _ in[0]*n]
print(len(set(''.join(s)for s in P(C,k))))
|
s642827987 | p00469 | u759949288 | 1361356162 | Python | Python | py | Runtime Error | 0 | 0 | 208 | from itertools import permutations
while True:
n = input()
if n == 0: break
k = input()
nums = [raw_input() for i in xrange(n)]
result = set("".join(p) for p in permutations(nums, k))
print len(result) |
s501333884 | p00469 | u759949288 | 1361356223 | Python | Python | py | Runtime Error | 0 | 0 | 213 | from itertools import permutations
while True:
n = input()
k = input()
if n == k == 0: break
nums = [raw_input() for i in xrange(n)]
result = set("".join(p) for p in permutations(nums, k))
print len(result) |
s317281631 | p00469 | u759949288 | 1361356925 | Python | Python | py | Runtime Error | 0 | 0 | 255 | from itertools import permutations
while True:
n = int(raw_input().strip())
k = int(raw_input().strip())
if n == k == 0: break
nums = [raw_input().strip() for i in xrange(n)]
result = set("".join(p) for p in permutations(nums, k))
print len(result) |
s386329876 | p00469 | u759949288 | 1361357001 | Python | Python | py | Runtime Error | 0 | 0 | 259 | from itertools import permutations
while True:
n = int(raw_input().strip())
k = int(raw_input().strip())
if n == k == 0:
break
nums = [raw_input().strip() for i in xrange(n)]
result = set(["".join(p) for p in permutations(nums, k)])
print len(result) |
s435834863 | p00469 | u759949288 | 1361357090 | Python | Python | py | Runtime Error | 0 | 0 | 154 | while True:
n = int(raw_input().strip())
k = int(raw_input().strip())
if n == k == 0:
break
nums = [raw_input().strip() for i in xrange(n)]
print 0 |
s796362694 | p00469 | u759949288 | 1361357301 | Python | Python | py | Runtime Error | 0 | 0 | 226 | from itertools import permutations
while True:
n = input()
k = input()
if n == k == 0:
break
nums = [raw_input().strip() for i in xrange(n)]
result = set(["".join(p) for p in permutations(nums, k)])
print(len(result)) |
s978886653 | p00469 | u759949288 | 1361357363 | Python | Python | py | Runtime Error | 0 | 0 | 243 | import sys
from itertools import permutations
while True:
n = input()
k = input()
if n == k == 0:
sys.exit(0)
nums = [raw_input().strip() for i in xrange(n)]
result = set(["".join(p) for p in permutations(nums, k)])
print(len(result)) |
s087184729 | p00469 | u759949288 | 1361357450 | Python | Python | py | Runtime Error | 0 | 0 | 307 | import sys
from itertools import permutations
def main():
while True:
n = input()
k = input()
if n == k == 0:
return 0
nums = [raw_input().strip() for i in xrange(n)]
result = set(["".join(p) for p in permutations(nums, k)])
print (len(result))
if __name__ == '__main__':
sys.exit(main()) |
s218009346 | p00469 | u759949288 | 1361357894 | Python | Python | py | Runtime Error | 0 | 0 | 321 | import sys
from itertools import permutations
def main():
while True:
n, k = map(int, raw_input().split())
if n == k == 0:
sys.exit(0)
nums = [raw_input().strip() for i in xrange(n)]
result = set(["".join(p) for p in permutations(nums, k)])
print (len(result))
if __name__ == '__main__':
sys.exit(main()... |
s611252533 | p00469 | u759949288 | 1361359865 | Python | Python | py | Runtime Error | 0 | 0 | 346 | import sys
from itertools import permutations
def main():
while True:
n = input()
k = input()
if n == k == 0:
sys.exit(0)
for i in xrange(n):
input()
# nums = [raw_input().strip() for i in xrange(n)]
# result = set(["".join(p) for p in permutations(nums, k)])
# print (len(result))
if __name__ == '__... |
s987634106 | p00469 | u104911888 | 1368799453 | Python | Python | py | Runtime Error | 0 | 0 | 212 | import itertools
while True:
n=input()
k=input()
if n==k==0:break
L=[raw_input() for i in range(n)]
S=set()
for t in itertools.permutations(L,k):
S.add("".join(t))
print len(S) |
s496589464 | p00469 | u104911888 | 1368799596 | Python | Python | py | Runtime Error | 0 | 0 | 273 | import itertools
while True:
n=raw_input()
if n in "0":break
try:
k=input()
except SyntaxError:
break
L=[raw_input() for i in range(int(n))]
S=set()
for t in itertools.permutations(L,k):
S.add("".join(t))
print len(S) |
s331159036 | p00470 | u150984829 | 1526200076 | Python | Python3 | py | Runtime Error | 0 | 0 | 262 | for e in iter(input,'0 0'):
w,h=map(int,e.split())
M=[[[1,0]*2 for _ in[0]*h]for _ in[0]*w]
for i in range(1,w):
for j in range(1,h):
a=M[i-1][j][:2]
b=M[i][j-1][2:]
M[i][j]=[b[1],a,a[1],b]
print((sum(M[w-2][h-1][:2])+sum(M[w-1][h-2][2:]))%10**5)
|
s643025090 | p00470 | u759949288 | 1361357766 | Python | Python | py | Runtime Error | 0 | 0 | 355 | import sys
from itertools import permutations
def main():
while True:
n = input()
k = input()
if n == k == 0:
return 0
for i in xrange(n):
input()
print "a"
# nums = [raw_input().strip() for i in xrange(n)]
# result = set(["".join(p) for p in permutations(nums, k)])
# print (len(result))
if __name... |
s816986110 | p00471 | u797673668 | 1457700748 | Python | Python3 | py | Runtime Error | 40000 | 7868 | 1865 | def search(town, remains, i, j):
if not remains:
if i == church[0]:
direction = 1 if j < church[1] else -1
for cj in range(j + direction, church[1], direction):
if town[i][cj] == 3:
return 0
return 1
elif j == church[1]:
... |
s435323488 | p00471 | u150984829 | 1526211381 | Python | Python3 | py | Runtime Error | 0 | 0 | 3380 | '''
今年も JOI 町にサンタクロースが空からやってきた.JOI 町にある全ての家には子供がいるので,この
サンタクロースは JOI 町の全ての家にプレゼントを配ってまわらなければならない.しかし,今年は連れ
ているトナカイが少々方向音痴であり,また建物の上以外に降りることができないため,全ての家にプレゼ
ントを配るためには少々道順を工夫しなければならないようだ.
JOI 町は東西南北に区画整理されており,各区画は家,教会,空き地のいずれかである.JOI 町には 1
つだけ教会がある.次のルールに従い,サンタクロースとトナカイは教会から出発し,全ての家に 1 回ず
つプレゼントを配った後,教会に戻る.
- 今年のトナカイは少... |
s093633991 | p00472 | u811434779 | 1443166057 | Python | Python | py | Runtime Error | 40000 | 16632 | 353 | DIV = 100000
n, m = map(int, raw_input().split())
l = [input() for _ in range(n-1)]
ans = [0]*(n-1)
pos = 0
for _ in range(m):
k = input()
if k > 0:
for i in range(k): ans[pos+i] += 1
else:
for i in range(-1, k-1, -1):
ans[pos+i] += 1
pos += k
print sum((ans[i] * l[i])... |
s242030032 | p00472 | u811434779 | 1443166493 | Python | Python | py | Runtime Error | 40000 | 10332 | 357 | DIV = 100000
n, m = map(int, raw_input().split())
l = [input() for _ in range(n-1)]
ans = [0]*(n-1)
pos = 0
for _ in xrange(m):
k = input()
if k > 0:
for i in xrange(k): ans[pos+i] += 1
else:
for i in xrange(-1, k-1, -1):
ans[pos+i] += 1
pos += k
print sum((ans[i] * l[... |
s710768916 | p00472 | u901080241 | 1496288042 | Python | Python3 | py | Runtime Error | 40000 | 9064 | 235 | n,m = map(int,input().split())
lng = []
for _ in range(n-1):
lng.append(int(input()))
i = 0
sm = 0
for _ in range(m):
j = i+int(input())
mv = sum(lng[i:j]) if j > i else sum(lng[j:i])
sm += mv
i = j
print(sm%100000) |
s754859966 | p00472 | u901080241 | 1496288224 | Python | Python3 | py | Runtime Error | 40000 | 9004 | 262 | n,m = map(int,input().split())
lng = []
for _ in range(n-1):
lng.append(int(input()))
i = 0
sm = 0
for _ in range(m):
j = i+int(input())
mv = sum(lng[i:j]) if j > i else sum(lng[j:i])
sm += mv
if sm >= 100000: sm -= 100000
i = j
print(sm) |
s347679962 | p00472 | u901080241 | 1496288598 | Python | Python3 | py | Runtime Error | 40000 | 9116 | 245 | n,m = map(int,input().split())
lng = []
for _ in range(n-1):
lng.append(int(input()))
i = 0
sm = 0
for _ in range(m):
j = i+int(input())
mv = sum(lng[i:j]) if j > i else sum(lng[j:i])
sm += mv
sm %= 100000
i = j
print(sm) |
s049881904 | p00472 | u011621222 | 1510225809 | Python | Python3 | py | Runtime Error | 0 | 0 | 1441 | # -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :
"""
#
# Author: Noname
# URL: https://github.com/pettan0818
# License: MIT License
# Created: 木 11/ 9 19:01:14 2017
# Usage
#
"""
from itertools import accumulate
def data_req():
n_yado, m_ryotei = [int(i) for i in input().spl... |
s539627994 | p00472 | u794549850 | 1391777407 | Python | Python | py | Runtime Error | 0 | 0 | 641 | #include <stdio.h>
int main() {
int i;
int n, m, now_pos, sum;
int s[100000];
int imos[100000];
scanf("%d %d", &n, &m);
for (i=0;i<n-1;i++) {
scanf("%d", &s[i]);
}
now_pos = 0;
for (i=0;i<m;i++) {
int a;
scanf("%d", &a);
if (a < 0) {
... |
s690409910 | p00473 | u621997536 | 1425296611 | Python | Python3 | py | Runtime Error | 19920 | 6708 | 18 | while True:
pass |
s048464451 | p00473 | u811434779 | 1444998291 | Python | Python | py | Runtime Error | 40000 | 8480 | 267 | n = input()
l = [input() for i in range(n-1)]
dp = [[n*n]*2 for i in range(n+1)]
dp[1][0] = 0
for i in range(1,n):
for j in range(i+1,0,-1):
dp[j][1] = min(dp[j][1], dp[j][0]+l[i-1])
dp[j][0] = min(dp[j-1][0], dp[j-1][1]+l[i-1])
print min(dp[n/2]) |
s786028238 | p00473 | u811434779 | 1444998655 | Python | Python | py | Runtime Error | 40000 | 8508 | 279 | INF = 1<<31
n = input()
l = [input() for i in range(n-1)]
dp = [[INF]*2 for i in range(n+1)]
dp[1][0] = 0
for i in range(1,n):
for j in range(i+1,0,-1):
dp[j][1] = min(dp[j][1], dp[j][0]+l[i-1])
dp[j][0] = min(dp[j-1][0], dp[j-1][1]+l[i-1])
print min(dp[n/2]) |
s268814968 | p00473 | u811434779 | 1445004338 | Python | Python | py | Runtime Error | 40000 | 7844 | 283 | INF = 1<<31
n = input()
l = [input() for i in xrange(n-1)]
dp = [[INF]*2 for i in xrange(n+1)]
dp[1][0] = 0
for i in xrange(1,n):
for j in xrange(i+1,0,-1):
dp[j][1] = min(dp[j][1], dp[j][0]+l[i-1])
dp[j][0] = min(dp[j-1][0], dp[j-1][1]+l[i-1])
print min(dp[n/2]) |
s379004160 | p00473 | u811434779 | 1445004695 | Python | Python | py | Runtime Error | 40000 | 7884 | 299 | INF = 1<<31
n = input()
l = [0]*(n+1)
for i in xrange(1,n):
l[i] = input()
dp = [[INF]*2 for i in xrange(n+1)]
dp[1][0] = 0
for i in xrange(1,n):
for j in xrange(i+1,0,-1):
dp[j][1] = min(dp[j][1], dp[j][0]+l[i])
dp[j][0] = min(dp[j-1][0], dp[j-1][1]+l[i])
print min(dp[n/2]) |
s751708361 | p00473 | u078042885 | 1485161261 | Python | Python3 | py | Runtime Error | 40000 | 7972 | 188 | dp=[0]+[1<<20]*10000
n=int(input())
for i in range(1,n):
a=int(input())
for j in range(i//2+1):
dp[j],dp[i-j]=map(min,[(dp[j],dp[i-j]+a),(dp[i-j],dp[j]+a)])
print(dp[n//2]) |
s383823053 | p00473 | u078042885 | 1485162354 | Python | Python3 | py | Runtime Error | 0 | 0 | 190 | dp=[0]+[1<<20]*10000
n=int(input())
for i in range(1,n+1):
a=int(input())
for j in range(i//2+1):
dp[j],dp[i-j]=map(min,[(dp[j],dp[i-j]+a),(dp[i-j],dp[j]+a)])
print(dp[n//2]) |
s525745808 | p00473 | u078042885 | 1485163079 | Python | Python3 | py | Runtime Error | 40000 | 8008 | 209 | dp=[0]+[1<<20]*10000
n=int(input())
for i in range(1,n):
try:a=int(input())
except:break
for j in range(i//2+1):
dp[j],dp[i-j]=map(min,[(dp[j],dp[i-j]+a),(dp[i-j],dp[j]+a)])
print(dp[n//2]) |
s901927841 | p00473 | u078042885 | 1485163922 | Python | Python3 | py | Runtime Error | 40000 | 8048 | 211 | dp=[0]+[1<<20]*10000
n=int(input())
for i in range(1,n+1):
try:a=int(input())
except:break
for j in range(i//2+1):
dp[j],dp[i-j]=map(min,[(dp[j],dp[i-j]+a),(dp[i-j],dp[j]+a)])
print(dp[n//2]) |
s876130401 | p00473 | u078042885 | 1485165587 | Python | Python3 | py | Runtime Error | 40000 | 8688 | 234 | import sys
dp=[0]+[1<<20]*10000
n=int(input())
a=list(map(int,sys.stdin.readlines()))
for i in range(1,len(a)):
for j in range(i//2+1):
dp[j],dp[i-j]=map(min,[(dp[j],dp[i-j]+a[i-1]),(dp[i-j],dp[j]+a[i-1])])
print(dp[n//2]) |
s377828182 | p00473 | u078042885 | 1485166106 | Python | Python3 | py | Runtime Error | 40000 | 8712 | 229 | import sys
dp=[0]+[1<<20]*10000
n=int(input())
a=list(map(int,sys.stdin.readlines()))
for i in range(1,n):
for j in range(i//2+1):
dp[j],dp[i-j]=map(min,[(dp[j],dp[i-j]+a[i-1]),(dp[i-j],dp[j]+a[i-1])])
print(dp[n//2]) |
s762863200 | p00473 | u078042885 | 1485168631 | Python | Python3 | py | Runtime Error | 40000 | 8632 | 337 | #???????????±???????????\????????°????????£?????????????
import sys
dp = [0] + [1 << 20] * 10000
n = int(input())
a = list(map(int, sys.stdin.readlines()))
if len(a)==n:a.pop()
for i in range(1, n) :
for j in range(i//2+1):
dp[j], dp[i - j] = map(min, [(dp[j], dp[i - j] + a[i - 1]), (dp[i - j], dp[j] + a[i - 1])])
p... |
s342568110 | p00473 | u078042885 | 1485171099 | Python | Python3 | py | Runtime Error | 40000 | 8064 | 225 | dp=[0]+[1<<20]*10000
n=int(input())
for i in range(1,n):
a=int(input())
for j in range(i//2+1):
dp[j],dp[i-j]=map(min,[(dp[j],dp[i-j]+a),(dp[i-j],dp[j]+a)])
print(dp[n//2])
try:raise RuntimeError
except:exit() |
s885014037 | p00473 | u078042885 | 1485172496 | Python | Python3 | py | Runtime Error | 40000 | 8048 | 195 | dp=[0]+[1<<20]*10000
n=int(input())
for i in range(1,n):
a=int(input())
for j in range(i//2+1):
dp[j],dp[i-j]=map(min,[(dp[j],dp[i-j]+a),(dp[i-j],dp[j]+a)])
print(dp[n//2])
exit() |
s742683095 | p00473 | u078042885 | 1485199651 | Python | Python3 | py | Runtime Error | 40000 | 7944 | 221 | dp=[0]+[1<<20]*10000
n=int(input())
c=0
for i in range(1,n):
if c==n-1:break
a=int(input())
c+=1
for j in range(i//2+1):
dp[j],dp[i-j]=map(min,[(dp[j],dp[i-j]+a),(dp[i-j],dp[j]+a)])
print(dp[n//2]) |
s601057742 | p00473 | u901080241 | 1496295240 | Python | Python3 | py | Runtime Error | 40000 | 7760 | 233 | n = int(input())
dp = [float('inf')]*(n+1)
dp[0] = 0
for i in range(1,n):
cost = int(input())
for j in range(i):
dp[j] = min(dp[j],dp[i-j]+cost)
dp[i-j] = min(dp[j]+cost,dp[i-j])
#print(dp)
print(dp[n//2]) |
s601773147 | p00473 | u352394527 | 1525788288 | Python | Python3 | py | Runtime Error | 17490 | 5976 | 733 | INF = 100
n = int(input())
l = [0 if i == 0 else int(input()) for i in range(n)]
#dp = [[[INF] * 2 for i in range(n // 2 + 1)] for j in range(n + 1)]
#
#dp[1][1][0] = 0
#dp[1][0][1] = 0
#
#for i in range(2,n + 1):
# for j in range(1,n // 2 + 1):
# dp[i][j][0] = min(dp[i - 1][j - 1][0], dp[i - 1][j - 1][1] + l[i - 1... |
s446184621 | p00474 | u266872031 | 1448045150 | Python | Python | py | Runtime Error | 40000 | 12936 | 861 | [N,L]=[int(x) for x in raw_input().split()]
icelist=[0]
for i in range(N):
icelist.append(int(raw_input()))
icelist.append(0)
incindex=[]
for i in range(1,N+1):
if icelist[i]>icelist[i-1] and icelist[i]>icelist[i+1]:
incindex.append(i)
ans=0
popped=0
while popped<N:
addindex=[]
delindex=[]
t... |
s761719295 | p00474 | u894114233 | 1470732389 | Python | Python | py | Runtime Error | 40000 | 11216 | 369 | n,l=map(int,raw_input().split())
a=[0]+[int(raw_input()) for _ in xrange(n)]+[0]
cnt=0
while a!=[0]*(n+2):
t_id=[]
max_t=-1
for i in xrange(1,n+1):
if a[i-1]<a[i] and a[i]>a[i+1]:
t_id.append(i)
if max_t<a[i]:
max_t=a[i]
cnt+=l-max_t
for i in t_id:
... |
s325073194 | p00474 | u894114233 | 1474977331 | Python | Python | py | Runtime Error | 40000 | 12912 | 609 | n,l=map(int,raw_input().split())
a=[0]+[int(raw_input()) for _ in xrange(n)]+[0]
r=[0]*(n+2)
for i in xrange(1,n+1):
if a[i-1]<a[i] and a[i]>a[i+1]:
r[i]=0
elif a[i-1]<a[i] and a[i]<a[i+1]:
r[i]=1
elif a[i-1]>a[i] and a[i]>a[i+1]:
r[i]=1
else:
r[i]=2
time=[0]*(n+2)
while ... |
s244480462 | p00474 | u894114233 | 1474978906 | Python | Python | py | Runtime Error | 40000 | 11064 | 379 | n,l=map(int,raw_input().split())
a=[0]+[int(raw_input()) for _ in xrange(n)]+[0]
ti=[0]*(n+2)
while a!=[0]*(n+2):
for i in xrange(1,n+1):
if a[i-1]<a[i] and a[i]>a[i+1]:
ti[i]+=l-a[i]
a[i]=0
if a[i-1]!=0:
ti[i-1]=max(ti[i-1],ti[i])
if a[i+1]!=0... |
s339179497 | p00474 | u198881450 | 1497439268 | Python | Python3 | py | Runtime Error | 0 | 0 | 865 | def greedy(N,L,ices):
counts = 0
while True:
for i in range(len(ices)):
if 0 < i < N-1:
if ices[i] > ices[i-1] and ices[i] > ices[i+1]:
ices[i] += 1
if ices[i] >= L:
ices[i] = 0
elif i == 0:
... |
s921684860 | p00474 | u945345165 | 1497439437 | Python | Python3 | py | Runtime Error | 40000 | 19460 | 766 | def update(arr, diff):
neoArr = []
for i in range(len(arr)):
tmp = 0
if i==0:
if arr[i]>arr[i+1]:
tmp = diff
elif i==len(arr)-1:
if arr[i]>arr[i-1]:
tmp = diff
else:
if arr[i]>arr[i-1] and arr[i]>arr[i+1]:
... |
s123801403 | p00474 | u198881450 | 1497439740 | Python | Python3 | py | Runtime Error | 0 | 0 | 940 | def greedy(N,L,ices):
counts = 1
while True:
# print(ices)
for i in range(len(ices)):
if 0 < i < N-1:
if ices[i] > ices[i-1] and ices[i] > ices[i+1]:
ices[i] += 1
if ices[i] >= L:
ices[i] = 0
... |
s217259789 | p00474 | u198881450 | 1497443016 | Python | Python3 | py | Runtime Error | 0 | 0 | 1723 | import copy
def greedy(N,L,ices):
counts = 1
while True:
# print(ices)
copied = copy.deepcopy(ices)
for i in range(len(ices)):
if copied[i] != 0:
if 0 < i < N-1:
if copied[i] >= L:
ices[i] = 0
... |
s074419093 | p00474 | u198881450 | 1497443040 | Python | Python3 | py | Runtime Error | 40000 | 14000 | 1725 | import copy
def greedy(N,L,ices):
counts = 1
while True:
# print(ices)
copied = copy.deepcopy(ices)
for i in range(len(ices)):
if copied[i] != 0:
if 0 < i < N-1:
if copied[i] >= L:
ices[i] = 0
... |
s427739111 | p00474 | u940389926 | 1497445626 | Python | Python3 | py | Runtime Error | 0 | 0 | 1455 | N, L = 0, 0
def loadIcicle():
N, L = 0, 0
i = 0
icicles = []
line = sys.stdin.readline().strip()
while True:
if i == 0:
N, L = int(line.split(" ")[0]), int(line.split(" ")[1])
i += 1
continue
line = sys.stdin.readline().strip()
if line == "": break
icicles.append(int(line))
i += 1
if i == N+1... |
s888920137 | p00474 | u028939600 | 1497454626 | Python | Python | py | Runtime Error | 0 | 0 | 711 | def orderN(N,L,ices):
upPeak = L - ices[0]
downPeak = L - ices[0]
peaks = []
for i in xrange(len(ices)):
if i < N-1:
if ices[i] < ices[i+1]:
peaks.append(downPeak)
downPeak = L - ices[i+1]
upPeak += L - ices[i+1]
else:
... |
s782493657 | p00474 | u028939600 | 1497494305 | Python | Python | py | Runtime Error | 0 | 0 | 675 | def orderN(N,L,ices):
upPeak = L - ices[0]
downPeak = L - ices[0]
peaks = []
for i in range(len(ices)):
if i < N-1:
if ices[i] < ices[i+1]:
peaks.append(downPeak)
downPeak = L - ices[i+1]
upPeak += L - ices[i+1]
elif ices[i]... |
s918860694 | p00474 | u940389926 | 1497534907 | Python | Python3 | py | Runtime Error | 0 | 0 | 1635 | ## ?????????
def loadIcicle():
icicles = []
line = input().strip().split(" ")
N, L = int(line[0]), int(line[1])
while True:
icicles.append(int(input().strip()))
if len(icicles) == N: break
return icicles, N, L
icicles, N, L = loadIcicle()
def calcDiff(icicles, N):
diff_2times = [0]*len(icicles)
for idx in ... |
s300274723 | p00474 | u940389926 | 1497545180 | Python | Python3 | py | Runtime Error | 0 | 0 | 1279 | def loadIcicle():
icicles = []
line = input().strip().split(" ")
N, L = int(line[0]), int(line[1])
for _ in range(N):
icicles.append(int(input().strip()))
return icicles, N, L
def calcDiff(icicles, N):
diff_2times = [0]*N
for idx in range(N):
dif_right = icicles[idx+1] - icicles[idx] if idx != N-1 else -ic... |
s075776604 | p00474 | u940389926 | 1497545624 | Python | Python3 | py | Runtime Error | 40000 | 7832 | 1367 | def loadIcicle():
icicles = []
line = input().strip().split(" ")
N, L = int(line[0]), int(line[1])
while True:
icicles.append(int(input().strip()))
if len(icicles) == N: break
return icicles, N, L
def calcDiff(icicles, N):
diff_2times = [0]*N
for idx in range(N):
dif_right = icicles[idx+1] - icicles[idx]... |
s059080085 | p00474 | u352394527 | 1525847571 | Python | Python3 | py | Runtime Error | 0 | 0 | 364 | def solve():
n,l = map(int,input().split())
length = [int(input()) for i in range(n)]
pare = [(length[i], i) for i in range(n)]
pare.sort(reverse=True)
dp = [0] * (n + 1)
for p in pare:
i = p[0]
if i == 0:
dp[i] = dp[i + 1] + (l - length[i])
else:
dp[i] = max(dp[i - 1], dp[i + 1])... |
s647594167 | p00476 | u811733736 | 1506311035 | Python | Python3 | py | Runtime Error | 40000 | 15616 | 1549 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0553
"""
import sys
from sys import stdin
from heapq import heappop, heappush
input = stdin.readline
def solve():
pass
def main(args):
N, H = map(int, input().split())
MAX_H = H
costs = []
wells = []
for _... |
s150254412 | p00476 | u811733736 | 1506338728 | Python | Python3 | py | Runtime Error | 40000 | 15652 | 1830 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0553
"""
import sys
from sys import stdin
from heapq import heappop, heappush
input = stdin.readline
def main(args):
N, H = map(int, input().split())
MAX_H = H
costs = []
wells = []
for _ in range(N - 1):
... |
s582936170 | p00476 | u811733736 | 1507118353 | Python | Python3 | py | Runtime Error | 40000 | 15688 | 3587 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0553
"""
import sys
from sys import stdin
from heapq import heappop, heappush
import time
input = stdin.readline
class RMQ(object):
INT_MAX = 2**31 - 1
def __init__(self, nn):
self.n = 1
while self.n < nn:
... |
s897465492 | p00478 | u235282710 | 1443690841 | Python | Python3 | py | Runtime Error | 0 | 0 | 145 |
keyword = raw_input()
N = int(raw_input())
count = 0
for _ in xrange(N):
s = raw_input()
if keyword in (s+s):
count += 1
print count |
s377655084 | p00479 | u145563629 | 1430825774 | Python | Python | py | Runtime Error | 19930 | 4252 | 611 | N = int(raw_input())
k = int(raw_input())
while k:
k -= 1
x, y = map(int, raw_input().split())
two = 0
while 1:
a_y = two + 1
a_x = two + 1
f = 0
for i in range(N - two * 2 - 1):
if x == a_x and y == a_y:
f = 1
break
a_y += 1
for i in range(N - two * 2 - 1):
if x == a_x and y == ... |
s403129742 | p00479 | u145563629 | 1430826408 | Python | Python | py | Runtime Error | 19930 | 4264 | 650 | N = int(raw_input())
k = int(raw_input())
lis = []
while k:
k -= 1
x, y = map(int, raw_input().split())
two = 0
while 1:
a_y = two + 1
a_x = two + 1
f = 0
for i in range(N - two * 2 - 1):
if x == a_x and y == a_y:
f = 1
break
a_y += 1
for i in range(N - two * 2 - 1):
if x == a_x ... |
s242477027 | p00479 | u145563629 | 1430827764 | Python | Python | py | Runtime Error | 19930 | 4268 | 688 | N = int(raw_input())
k = int(raw_input())
lis = []
while k:
k -= 1
x, y = map(int, raw_input().split())
two = 0
f = 0
while f != 1:
a_y = two + 1
a_x = two + 1
for i in range(N - two * 2 - 1):
if x == a_x and y == a_y:
f = 1
break
a_y += 1
for i in range(N - two * 2 - 1):
if x == ... |
s381579662 | p00479 | u560838141 | 1364457064 | Python | Python | py | Runtime Error | 0 | 0 | 128 | s = input()
n = input()
for i in range(n):
x, y = input()-1, input()-1
p = min(x, y, s - x - 1, s - y - 1)
print p % 3 + 1 |
s024923712 | p00479 | u104911888 | 1375353316 | Python | Python | py | Runtime Error | 170 | 12144 | 346 | N=input()
L=[[0]*N for i in range(N)]
R,B,Y=1,2,3
C=R
for y in range(N/2+1):
for x in range(y,N-y):
L[y][x]=C
L[N-y-1][x]=C
C=C%3+1
C=R
for x in range(N/2+1):
for y in range(x,N-x):
L[y][x]=C
L[y][N-x-1]=C
C=C%3+1
for i in range(input()):
a,b=map(int,raw_input().spli... |
s840984216 | p00480 | u227162786 | 1490179975 | Python | Python3 | py | Runtime Error | 0 | 0 | 510 | while True:
N = int(input())
if N == 0:
break
a = list(map(int, input().split()))
## dp[i][j]: i???????????°????????§??§j????????????????????°
dp = [[0 for j in range(21)] for i in range(N-1)]
dp[0][a[0]] = 1
for i in range(1, N-1):
for j in range(21):
if (j - a... |
s232391770 | p00480 | u227162786 | 1490180034 | Python | Python3 | py | Runtime Error | 0 | 0 | 441 | while True:
N = int(input())
if N == 0:
break
a = list(map(int, input().split()))
dp = [[0 for j in range(21)] for i in range(N-1)]
dp[0][a[0]] = 1
for i in range(1, N-1):
for j in range(21):
if (j - a[i]) in range(21):
dp[i][j] += dp[i-1][j-a[i]]
... |
s721629079 | p00480 | u469154576 | 1495612248 | Python | Python3 | py | Runtime Error | 0 | 0 | 357 | n = int(input())
a = list(map(int, input().split()))
dp = [[0] * 21 for i in range(n)]
dp[0][0] = 1
for i in range(n - 1):
for j in range(21):
if dp[i][j] == 0:
continue
if 0 <= j + a[i] <= 20:
dp[i + 1][j + a[i]] += dp[i][j]
if 0 <= j - a[i] <= 20:
dp[i + 1][j - a[i]] +... |
s254877058 | p00480 | u371539389 | 1496037461 | Python | Python3 | py | Runtime Error | 40000 | 7636 | 498 | def calc(num,ans):
if len(num)==1:
if num[0]==ans:
return 1
else:
return 0
else:
a=num.copy()
x=a.pop(-1)
if ans-x>=0 and ans+x<=20:
return calc(a,ans-x)+calc(a,ans+x)
elif ans-x>=0:
return calc(a,ans-x)
elif... |
s245454376 | p00480 | u228488524 | 1512970956 | Python | Python3 | py | Runtime Error | 0 | 0 | 424 | n = int(input)
inp = input()
nums = [int(i) for i in inp.split()]
ans = nums[-1]
dp = [[0 for j in range(21)] for i in range(n)]
dp[0][nums[0]] = 1
for i in range(1,n-1):
for j in range(21):
if dp[i-1][j] == 0:
continue
p = j + nums[i]
if p <= 20:
dp[i][p] += dp[i-1... |
s501255635 | p00480 | u228488524 | 1512971240 | Python | Python3 | py | Runtime Error | 0 | 0 | 413 | n = int(input)
nums = [int(i) for i in input().split()]
ans = nums[-1]
dp = [[0 for j in range(21)] for i in range(n)]
dp[0][nums[0]] = 1
for i in range(1,n-1):
for j in range(21):
if dp[i-1][j] == 0:
continue
p = j + nums[i]
if p <= 20:
dp[i][p] += dp[i-1][j]
... |
s653125441 | p00480 | u104911888 | 1386318788 | Python | Python | py | Runtime Error | 0 | 0 | 367 | n = input()
s = map(int, raw_input().split())
ans = s[-1]
dp = [[0] * 21 for i in range(n)]
dp[0][s[0]] = 1
for i in range(1, n-1):
for j in range(21):
if dp[i-1][j] == 0: continue
vp = j + s[i]
vm = j - s[i]
if vp <= 20:
dp[i][vp] += dp[i-1][j]
if 0 <= vm:
... |
s236704328 | p00481 | u617183767 | 1421114799 | Python | Python | py | Runtime Error | 19930 | 57436 | 1577 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import itertools
import math
from collections import Counter, defaultdict
class Main(object):
def __init__(self):
pass
def solve(self):
'''
insert your code
'''
h, w, n = map(int, raw_input().spli... |
s187970296 | p00481 | u617183767 | 1421117313 | Python | Python | py | Runtime Error | 19930 | 141836 | 2015 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import itertools
import math
from collections import Counter, defaultdict
class Main(object):
def __init__(self):
pass
def solve(self):
'''
insert your code
'''
h, w, n = map(int, raw_input().spli... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.