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
s641423998
p04005
u837286475
1473571553
Python
Python (3.4.3)
py
Runtime Error
39
3188
411
N,x = map(int,input().split()) lst = list( map(int,input().split() ) ) ans = sum(lst) dp = lst[:] #print(N,x) #print(lst) for i in range(1,N): tmp = 0 for k in range(0,N): index_ = 0 if(0 <= k-i): index_ = k-i else: index_ = N-i+k dp[k] = min(dp[k],...
s746003662
p04005
u010075034
1473128156
Python
Python (3.4.3)
py
Runtime Error
38
3064
319
def main(): ints = (int(_) for _ in input().split(' ')) if any(_ % 2 == 0 for _ in ints): print(0) return t = max(ints) x, y, z = ints if t == x: print(y * z) elif t == y: print(x * z) elif t == z: print(x * y) if __name__ == '__main__': main()
s133089835
p04005
u010075034
1473127873
Python
Python (3.4.3)
py
Runtime Error
38
3064
292
if __name__ == '__main__': x, y, z = (int(_) for _ in input().split(' ')) if x % 2 == 0 or y % 2 == 0 or z % 2 == 0: print(0) return t = max((x, y, z)) if t == x: print(y * z) elif t == y: print(x * z) elif t == z: print(x * y)
s834177418
p04005
u091855288
1473101376
Python
Python (2.7.6)
py
Runtime Error
157
10420
205
import numpy as np import copy a = map(int,raw_input().split()) def myfunc(a): A.sort(reverse=True) if (A[0]%2 != 0 and A[1]%2 !=0 and A[2]%2 != 0): print A[1]*A[2] else: print 0 myfunc(a)
s112571289
p04005
u516438812
1473084975
Python
Python (3.4.3)
py
Runtime Error
42
3184
218
A,B,C = map(int,input().split()) if A % 2 == 0 or B % 2 == 0 or C % 2 == 0: print(0) return S = A * B * C mi = min(A,min(B,C)) ma = max(A,max(B,C)) mid = S // ma // mi // 2 ans = ma * mi * mid print(abs(S - ans * 2))
s169478662
p04005
u837286475
1473058365
Python
Python (3.4.3)
py
Runtime Error
38
3064
243
a,b,c = map(int,input().split()) lst = [a,b,c] cnt = len(list( filter(lambda x:x%2==0,lst))) if(0<cnt): print(0) else: lst.sort() res = 0 if(lst[2]%2 == 1): res = lst[0]*lst[1] else: res = 0 prin
s285906466
p04005
u601018334
1473044979
Python
Python (3.4.3)
py
Runtime Error
37
3064
443
N, x = list(map(int, input().split())) a = list(map(int, input().split())) min_index = a.index(min(a)) index_list = list(range(min_index,N)) + list(range(min_index)) cost = a.copy() c_count = [0]*N for i in range(1,N): if cost[index_list[i]] > (cost[index_list[i-1]]+x): cost[index_list[i]] = cost[index_list...
s959814121
p04005
u436484848
1473044171
Python
Python (3.4.3)
py
Runtime Error
36
3064
149
str = input() num = list(map(int,str.split(' '))) if (num[0]%2)and(num[1]%2)and(num[2])==0: print(0) else: num.sort() print(num[0]*num[1])
s470573294
p04005
u436484848
1473043929
Python
Python (3.4.3)
py
Runtime Error
39
3064
152
str = input() num = list(map(int,str.split(' '))) if (num[0]%2)*(num[1]%2)*(num[2])==1: num.sort() print(num[0]*num[1]) else: print(0)
s314111636
p04005
u436484848
1473043769
Python
Python (3.4.3)
py
Runtime Error
37
3064
135
str = input() num = list(map(int,str.split(' '))) if !(num[0]%2)*(num[1]%2)*(num[2]): print(0) else: num.sort() print(num[0]*num[1])
s044929033
p04005
u866746776
1473040585
Python
Python (3.4.3)
py
Runtime Error
39
3064
430
def solve(n, x, a): costs = [] cost_min = 0 for k in range(n): if k == 0: costs = a.copy() else: for i in range(n): costs[i] = min(costs[i], a[(i-k)%n]) cost_k = sum(costs) + k*x if k == 0: cost_min = cost_k else: cost_min = min(cost_min, cost_k) if cost_min < (k+1) *x: break retur...
s349125909
p04005
u010075034
1473039791
Python
Python (3.4.3)
py
Runtime Error
39
3064
222
#!/usr/bin/env python3 if __name__ == '__main__': N, x = (int(_) for _ in input().split(' ')) As = [int(_) for _ in input().split(' ')] each = sum(As) change = (N - 1) * x + N print(min(each, change))
s357005931
p04005
u010075034
1473038769
Python
Python (3.4.3)
py
Runtime Error
37
3064
294
if __name__ == '__main__': x = int(input()) y = int(input()) z = int(input()) lst = (x, y, z) a = max(lst) if a == x: b, c = y, z elif a == y: b, c = x, z elif a == z: b, c = x, y print(((a - (a // 2)) * b * c) - ((a // 2) * b * c))
s530520046
p04005
u010075034
1473038345
Python
Python (3.4.3)
py
Runtime Error
40
3188
218
if __name__ == '__main__': x = int(input()) y = int(input()) z = int(input()) t = (x, y, z) a = max(t) b, c = [_ for _ in t if _ != a] print(((a - (a // 2)) * b * c) - ((a // 2) * b * c))
s395762583
p04005
u177721681
1473038057
Python
Python (2.7.6)
py
Runtime Error
26
2568
425
from sys import stdin from sys import stdout A,B,C = stdin.readline().split() if A%2 == 0 or B%2 == 0 or C%2 == 0 : print 0 exit() AB = int(A) * int(B) BC =...
s928162301
p04005
u132360211
1473038021
Python
Python (2.7.6)
py
Runtime Error
26
2568
152
io = STDIN a,b,c=io.gets.chomp.split.map(&:to_i) p [(a*b*(c/2)-a*b*(c-(c/2))).abs, (c*b*(a/2)-c*b*(a-(a/2))).abs, (a*c*(b/2)-a*c*(b-(b/2))).abs].min
s700164432
p04005
u530850765
1473037674
Python
Python (3.4.3)
py
Runtime Error
42
3316
169
a,b,c = (int(x) for x in input()) ans = abs(a*b*(c//2)-a*b*(c-c//2)) ans = min(ans, abs(a*c*(b//2)-a*c*(b-b//2))) ans = min(ans, abs(b*c*(a//2)-b*c*(a-a//2))) print(ans)
s556051583
p04006
u493520238
1601347319
Python
PyPy3 (7.3.0)
py
Runtime Error
1270
71424
1779
# 0-indexed class SegTree: def __init__(self, vals, seg_f, ide_ele): n = len(vals) self.seg_f = seg_f self.ide_ele = ide_ele self.leaf_n = 1 << (n-1).bit_length() self.tree = [ide_ele]*(2*self.leaf_n-1) for i in range(n): # init leaf self.tree[i+self.leaf...
s594163422
p04006
u423585790
1590435983
Python
PyPy3 (2.4.0)
py
Runtime Error
214
71808
246
n,x=map(int,input().split()) A=list(map(int,input().split())) ans=0 dp=[[A[i]]*n for i in range(n)] for l in range(n): a=A[l:]+A[:l] a=a[::-1] for i in range(n): dp[l][i+1]=min(dp[l][i],a[i]+x*(i+1)) print(sum(map(lambda x:x[-1], dp)))
s969365719
p04006
u423585790
1590434975
Python
PyPy3 (2.4.0)
py
Runtime Error
223
41180
268
n,x=map(int,input().split()) A=list(map(int,input().split())) ans=0 m=0 r=0 for l in range(n): a=A[l:]+A[:l] a=a[::-1] tmp=A[l] r=A[r] for i in range(n): if tmp>a[i]+x*(i+1): r=a[i] tmp=a[i]+x*(i+1) m=max(i+1,m) ans+=r print(ans+m*x)
s095670006
p04006
u922449550
1589680494
Python
PyPy3 (2.4.0)
py
Runtime Error
178
38640
275
N, x = map(int, input().split()) A = list(map(int, input().split())) min_time = A.copy() ans = 10**15 for t in range(N): time = t*x for i in range(N): j = (i - t) % N min_time[i] = min(min_time[i], A[j]) time += min_time[i] ans = min(ans, time) print(ans)
s126596184
p04006
u843135954
1588734074
Python
Python (3.4.3)
py
Runtime Error
19
3188
379
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nn = lambda: list(stdin.readline().split()) ns = lambda: stdin.readline().rstrip() n,i = na() a = na() dp = [i for i in a] ans = sum(dp) for i in range(1,n): for j in range(n): dp[(j+i)%n] = min(dp[...
s401760883
p04006
u648212584
1587824867
Python
PyPy3 (2.4.0)
py
Runtime Error
185
39408
387
import sys input = sys.stdin.buffer.readline def main(): N,x = map(int,input().split()) a = list(map(int,input().split())) b = a.copy() ans = 10**15 for i in range(N): time = i*x+sum(b) ans = min(ans,time) for now in range(N): b[now] = min(b[now],a[(now-i-1+...
s852204809
p04006
u476604182
1584561583
Python
PyPy3 (2.4.0)
py
Runtime Error
181
38768
254
from itertools import accumulate as acc N, x, *A = map(int, open(0).read().split()) dp = [] for i in range(N): dp.append(list(acc((A[(i-j)%N] for j in range(N)),min))) ans = 10**10 for i,a in enumerate(zip(*dp)): ans = min(ans,i*x+sum(a)) print(ans)
s799130764
p04006
u476604182
1584561573
Python
PyPy3 (2.4.0)
py
Runtime Error
181
38256
256
from itertools import accumulate as acc N, x, *A = map(int, open('0').read().split()) dp = [] for i in range(N): dp.append(list(acc((A[(i-j)%N] for j in range(N)),min))) ans = 10**10 for i,a in enumerate(zip(*dp)): ans = min(ans,i*x+sum(a)) print(ans)
s987488288
p04006
u186838327
1583367013
Python
Python (3.4.3)
py
Runtime Error
18
3192
1789
def segfunc(x, y): return min(x, y) class segment_(): def __init__(self, init_val, n, segfunc): self.ide_ele = 10**9+1 # num: n以上の最小の2のべき乗 self.num = 2**(n-1).bit_length() self.seg = [self.ide_ele]*2*self.num self.segfunc = segfunc # set_val for i in rang...
s033913099
p04006
u298297089
1571703959
Python
Python (3.4.3)
py
Runtime Error
1326
3316
384
n,x = map(int, input().split()) a = list(map(int, input().split())) ans = 0 mx = 0 inf = float('INF') for i in range(n): mn = a[i] con = a[i] for j in range(i-n,i+1): idx = (i-j)%n if mn > a[idx] + (i-j) * x: mn = a[idx] + (i-j) * x con = a[idx] if mx < t...
s813300931
p04006
u623687794
1570654417
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38768
327
n,x=map(int,input().split()) a=list(map(int,input().split())) a*=2 INF=10**15 cost=[INF]*n b=[(c,d) for i in enumerate(a)] b.sort(key=lambda x:x[1]) start=b[0][1] cost[start]=a[start] for i in range(start+1,start+n): cost[i%n]=min(cost[(i-1)%n]+x,cost[i%n]) ans=0 for i in cost: if i==INF:continue ans+=i pri...
s491888180
p04006
u143509139
1570488561
Python
PyPy3 (2.4.0)
py
Runtime Error
215
40688
239
n, x = map(int, input().split()) a = list(map(int, input().split())) d = a.copy() ans = float('inf') for i in range(n): ans = min(ans, sum(d) + x * i) for j in range(n): d[j] = min(d[j], a[(j - (i + 1) + n) % n]) print(ans)
s403672941
p04006
u532966492
1564980871
Python
Python (3.4.3)
py
Runtime Error
26
3572
625
from copy import deepcopy as dc #n,x=map(int,input().split()) x=int(input()) # a=list(map(int,input().split())) n=len(a) # a=[[i,i,0] for i in a] aa=dc(a) b=[] m=0 while(b!=a): b=dc(a) for _ in range(2): for i in range(n): j=i-1 if j==-1: j=n-1 if a[...
s651188657
p04006
u532966492
1564980127
Python
Python (3.4.3)
py
Runtime Error
22
3444
603
from copy import deepcopy as dc #n,x=map(int,input().split()) x=int(input()) # a=list(map(int,input().split())) n=len(a) # a=[[i,i,0] for i in a] b=[] m=0 while(b!=a): b=dc(a) for _ in range(2): for i in range(n): j=i-1 if j==-1: j=n-1 if a[i][1]!=a[j...
s861315379
p04006
u623687794
1557517269
Python
Python (3.4.3)
py
Runtime Error
18
2940
104
N,x = int(input().split()) a = sorted(list(map(int,input().split()))) print(min(N*a[0]+(N-1)*x,sum(a)))
s533169261
p04006
u095426154
1556331104
Python
Python (3.4.3)
py
Runtime Error
18
3064
532
n,x=map(int,input().split()) a=list(map(int,input().split())) t=[a[i] for i in range(n)] sp_cnt=[0 for i in range(n)] for i in range(1,n): if a[n-i]+i*x<t[0]: t[0]=a[n-i] sp_cnt[0]=i for i in range(1,n): for j in range(n): if i-j>=0: if a[i-j]+j*x<t[i]: t[i]=...
s171621829
p04006
u095426154
1556331039
Python
Python (3.4.3)
py
Runtime Error
17
3064
534
n,x=map(int,input().split()) a=list(map(int,input().split())) t=[a[i] for i in range(n)] sp_cnt=[0 for i in range(n)] for i in range(1,n): if a[n-i]+i*x<t[0]: t[0]=a[n-i] sp_cnt[0]=i for i in range(1,n): for j in range(n): if i-j>=0: if a[i-j]+j*x<t[i]: t[i]=...
s170961821
p04006
u095426154
1556329160
Python
Python (3.4.3)
py
Runtime Error
17
2940
459
n,x=map(int,input().split()) a=list(map(int,input().split())) dp=[a[i] for i in range(n)] sp_cnt[0 for i in range(n)] for i in range(1,n): if a[n-i]+i*x<dp[0]: dp[0]=a[n-1]+i*x sp_cnt[0]=i for i in range(1,n): for j in range(i): if a[i-j]+j*x<dp[0]: dp[i]=a[i-j]+j*x ...
s887876342
p04006
u069838609
1554690964
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38804
668
import sys fin = sys.stdin.readline N, x = [int(elem) for elem in fin().split()] a_list = [int(elem) for elem in fin().split()] min_cost_for = a_list.copy() this_is_from = list(range(N)) max_num_magics = 0 for i, a in enumerate(a_list): for j, other_a in enumerate(a_list): if i == j: continue n...
s263694653
p04006
u572144347
1554690779
Python
PyPy3 (2.4.0)
py
Runtime Error
212
39152
278
N,X = map(int, input().split()) A = list(map(int, input().split())) # ans = 10**13 ans = float("inf") for k in range(N): tmp = k * X for i in range(2*N): j = (i-k+N*4) % N A[i] = min(A[i], A[j]) tmp += sum(A) ans = min(ans, tmp) print(ans)
s320733535
p04006
u555962250
1554420281
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38384
289
import numpy as np N, x = map(int, input().split()) a = np.array(list(map(int, input().split()))) min_a = a.copy() ans = 10 ** 18 for i in range(N): s = x * i for j in range(N): min_a[j] = min(min_a[j], a[(i + j) % N]) s += min_a[j] ans = min(ans, s) print(ans)
s792290457
p04006
u785578220
1552361207
Python
Python (3.4.3)
py
Runtime Error
163
12500
233
import numpy as np N, x = map(int, input().split()) a = np.array(map(int, input().split())) b = np.copy(a) ans = float('inf') for i in range(N): c = np.roll(a,i) b = np.minimum(b,c) ans = min(ans, sum(b)+i*x) print(ans)
s582122424
p04006
u785578220
1552361192
Python
PyPy3 (2.4.0)
py
Runtime Error
184
38384
234
import numpy as np N, x = map(int, input().split()) a = np.array(map(int, input().split())) b = np.copy(a) ans = float('inf') for i in range(N): c = np.roll(a,i) b = np.minimum(b,c) ans = min(ans, sum(b)+i*x) print(ans)
s417303129
p04006
u785578220
1552361023
Python
PyPy3 (2.4.0)
py
Runtime Error
191
39664
248
def inpl(): return [int(i) for i in input().split()] import numpy as np N, x = inpl() a = np.array(inpl()) b = np.copy(a) ans = float('inf') for i in range(N): c = np.roll(a,i) b = np.minimum(b,c) ans = min(ans, sum(b)+i*x) print(ans)
s903772612
p04006
u223904637
1551986927
Python
Python (3.4.3)
py
Runtime Error
22
3188
291
n,x=map(int,input().split()) li=list(map(int,input().split())) mi=min(li) ind=-1 for i in range(n): if mi==li[i]: ind=i ans=[0]*n ans[0]=li[ind] k=0 for i in range(1,n): if ind+i>=n: k=ind+i-n else: k=ind+i ans[i]=min(li[k],ans[i-1]+x) print(sun(ans))
s729309097
p04006
u594567187
1551132421
Python
PyPy3 (2.4.0)
py
Runtime Error
189
39408
353
loop, magic_cost = map(int, input().split(" ")) cost = [n for n in map(int, input().split(" "))] answer = float("inf") min_costs = [float(inf) for n in range(loop)] for i in range(loop): for j in range(loop): min_costs[j] = min(min_costs[j], cost[(i - j) % loop]) answer = min(answer, sum(min_costs) + (m...
s864728423
p04006
u427344224
1548368896
Python
PyPy3 (2.4.0)
py
Runtime Error
177
38768
293
N, x = map(int, input().split()) a_list = list(map(int, input().split())) ex_list = a_list.copy() ex_list.extend(a_list) ans = float("inf") for i in range(N): cost = 0 for j in range(N): cost += min(ex_list[N-i+j:N+1+j]) cost += x * i ans = min(ans, cost) print(ans)
s059139194
p04006
u732285858
1531505124
Python
Python (3.4.3)
py
Runtime Error
17
2940
1091
#include <iostream> #include <algorithm> #include <cmath> #include <map> #include <vector> #include <queue> #include <functional> #include <string> #include <stack> #include <set> #include <sstream> #include <iomanip> #include <limits> using namespace std; using ll = long long; typedef unsigned long long ull; typedef p...
s519734963
p04006
u582763758
1528567566
Python
Python (3.4.3)
py
Runtime Error
17
2940
626
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mx = 4005; const ll inf = 4e18; ll dp[mx], rdp[mx]; ll a[mx]; ll x; int n; int main(){ ios_base::sync_with_stdio(false);cin.tie(0); cin >> n >> x; for(int i = 0; i < n; i++) cin >> a[i]; copy(a,a+n,a+n); for(int i = 0; i...
s343344576
p04006
u132291455
1477170022
Python
Python (2.7.6)
py
Runtime Error
18
2812
195
n,x=map(int,raw_input().split(" ")) a=map(int,raw_input().split(" ")) t=[i for i in a] ans=10**10 for m in range(n): t=[min(t[j],a[(j-m)%n]) for j in range(n)] s=min(x*m+sum(t),s) print s
s770991907
p04006
u442810826
1473156612
Python
Python (2.7.6)
py
Runtime Error
1931
139240
232
N, x = map(int, raw_input().split()) A = map(int, raw_input().split()) A = A+A b = [[A[i-j]+x*j for i in range(N,2*N)] for j in range(N)] c = [min(bb) for bb in b] d = [bb.index(cc) for cc in c] print sum(c) - x * (sum(d)-max(d))
s231282511
p04006
u124139453
1473136244
Python
Python (3.4.3)
py
Runtime Error
38
3064
396
n, x = map(int, raw_input().split()) a = map(int, raw_input().split()) ans = 0 b = [] for k in range(n): if k == 0: b = a[:] else: for i in range(n): b[i] = min(a[(i-k)%n],b[i]) cost = k*x+sum(b) if k == 0: ans = cost else: ans = min(ans,cost) if a...
s299481916
p04006
u124139453
1473135920
Python
Python (2.7.6)
py
Runtime Error
30
2804
399
n, x = map(int, raw_input().split()) a = map(int, raw_input().split()) ans = 0 b = [] for k in range(n): if k == 0: b = a.copy() else: for i in range(n): b[i] = min(a[(i-k)%n],b[i]) cost = k*x+sum(b) if k == 0: ans = cost else: ans = min(ans,cost) ...
s499957980
p04006
u124139453
1473134714
Python
Python (2.7.6)
py
Runtime Error
32
2812
193
n, x = map(int, raw_input().split()) a = map(int, raw_input().split()) b = a[:] for k in range(n): for i in range(n): b[i] = min(a[i-k],b[i]) ans = min(ans,k*x+sum(b)) print ans
s906934679
p04006
u601018334
1473129274
Python
Python (3.4.3)
py
Runtime Error
39
3064
412
def solve_(): import itertools N, x = map(int, input().split()) a = list(map(int, input().split())) s_cost = a.copy() cost = sum(s_cost) for k, i in itertools.product(range(1, N), range(N)): s_cost[i] = a[(i - k) % N] if s_cost > a[(i - k) % N] else s_cost[i] if i == N - 1 and c...
s804922815
p04006
u443010331
1473084208
Python
Python (2.7.6)
py
Runtime Error
31
2820
274
import math N, x = map(int, raw_input().split()) A = map(int, raw_input().split()) ans = 1e18 b = [[ans for i in range(N)]] for k in range(N): sum = k*x for i in range(N): b[i] = min(b[i], A[(i+N-k)%N]) sum += b[i] ans = min(ans, sum) print ans
s029745429
p04006
u601018334
1473069533
Python
Python (3.4.3)
py
Runtime Error
40
3188
290
N, x = list(map(int, input().split())) a = list(map(int, input().split())) s_cost = a cost = sum(s_cost) for k in xrange(0,N): s_cost = [min(s_cost[x],a[y]) for (x,y) in zip( list(xrange(N)), list(xrange(N-k,N))+list(xrange(N-k)) )] cost = min(cost, k*x + sum(s_cost)) print(cost)
s755121868
p04006
u601018334
1473059257
Python
Python (3.4.3)
py
Runtime Error
38
3064
444
N, x = list(map(int, input().split())) a = list(map(int, input().split())) min_index = a.index(min(a)) index_list = list(range(min_index,N)) + list(range(min_index)) cost = a.copy() c_count = [0]*N for i in range(1,N): if cost[index_list[i]] => (cost[index_list[i-1]]+x): cost[index_list[i]] = cost[index_lis...
s464339687
p04006
u226155577
1473043350
Python
Python (2.7.6)
py
Runtime Error
30
2804
561
n, x = map(int, raw_input().split()) A = map(int, raw_input().split())*2 ans = 10**18 for l in xrange(1, n+1): deq = [0]*n s = t = 0 res = 0 for i in xrange(n): while s<t and A[deq[t-1]] >= A[i]: t -= 1 deq[t] = i t += 1 if deq[s] == i-l+1: s += 1 ...
s531836362
p04006
u457552420
1473040040
Python
Python (2.7.6)
py
Runtime Error
27
2568
536
ef cast(curr, num): arr = [(x+num) % N for x in curr] return arr def transform(curr, val): ret = 0 while ((val-ret + N) % N) in curr: ret += 1 return ret N, x = map(int, raw_input().split()) a = map(int, raw_input().split()) curr = [] ans = 0 while len(curr) < N: cost = list(a) t...
s475371819
p04007
u785989355
1560153592
Python
Python (3.4.3)
py
Runtime Error
19
3316
770
H,W = list(map(int,input().split())) a = [input() for i in range(H)] b = [[] for i in range(H)] r = [[] for i in range(H)] for i in range(H): for j in range(W): if i==0: b[i].append("#") r[i].append(".") elif i==H-1: b[i].append(".") r[i].append("#"...
s572223935
p04007
u091855288
1473104898
Python
Python (2.7.6)
py
Runtime Error
28
2696
679
import numpy as np import copy a = map(int,raw_input().split()) H = a[0] W = a[1] A = [] for idx in xrange(H): A.append( list(raw_input()) ) def textMap(A): A = np.array(A, dtype='S') A[A!='0'] = '#' A[A=='0'] = '.' texts = [] for vec in A: texts.append( ''.join(vec) ) return '\n'.join(texts) def m...
s494501457
p04008
u794173881
1591232248
Python
PyPy3 (2.4.0)
py
Runtime Error
185
43000
1073
import sys def query(num): # output print("?", num) sys.stdout.flush() # input res = input() return res ans = "" while True: if len(ans) == 0: # 最上位桁のときは1からスタート min_lim = 1 else: min_lim = 0 for char in range(min_lim, 10): tmp = ans + str(char) ...
s296855272
p04008
u423585790
1590165133
Python
PyPy3 (2.4.0)
py
Runtime Error
1064
208616
406
import sys sys.setrecursionlimit(10**6) n,k = map(int,input().split()) a = [int(i)-1 for i in input().split()] edg = [[] for i in range(n)] for i in range(1,n): edg[a[i]].append(i) ans = [0] * n ans[0] = a[0] != 0 def dfs(now): res = 0 for e in edg[now]: res = max(res, dfs(e)) if res == k - 1 and a[e] != 0 ...
s133781054
p04008
u423585790
1590163943
Python
PyPy3 (2.4.0)
py
Runtime Error
754
183276
413
import sys sys.setrecursionlimit(10**6) n,k = map(int,input().split()) a = [int(i)-1 for i in input().split()] edg = [[] for i in range(n)] for i in range(n): edg[a[i]].append(i) ans = [0] * n ans[0] = a[0] != 0 c = [1] * n def dfs(now, rank): c[now] = 0 for e in edg[now]: if c[e]: if rank == k: ...
s267170474
p04008
u423585790
1590163470
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38384
410
import sys sys.recursionlimit(10**6) n,k = map(int,input().split()) a = [int(i)-1 for i in input().split()] edg = [[] for i in range(n)] for i in range(n): edg[a[i]].append(i) ans = [0] * n ans[0] = a[0] != 0 c = [1] * n def dfs(now, time): c[now] = 0 for e in edg[now]: if c[e]: if time == k: an...
s672630112
p04008
u423585790
1590163380
Python
PyPy3 (2.4.0)
py
Runtime Error
583
106608
373
n,k = map(int,input().split()) a = [int(i)-1 for i in input().split()] edg = [[] for i in range(n)] for i in range(n): edg[a[i]].append(i) ans = [0] * n ans[0] = a[0] != 0 c = [1] * n def dfs(now, time): c[now] = 0 for e in edg[now]: if c[e]: if time == k: ans[e] = 1 dfs(e, 1) else...
s817289383
p04008
u423585790
1590163020
Python
PyPy3 (2.4.0)
py
Runtime Error
564
103920
366
n,k = map(int,input().split()) a = [int(i)-1 for i in input().split()] edg = [[] for i in range(n)] for i in range(n): edg[a[i]].append(i) ans = a[0] != 0 c = [1] * n def dfs(now, time): global ans c[now] = 0 for e in edg[now]: if c[e]: if time == k: ans += 1 dfs(e, 1) else: ...
s692400564
p04008
u423585790
1590162888
Python
PyPy3 (2.4.0)
py
Runtime Error
569
103920
361
n,k = map(int,input().split()) a = [int(i)-1 for i in input().split()] edg = [[] for i in range(n)] for i in range(n): edg[a[i]].append(i) ans = a[0] != 0 c = [1] * n def dfs(now, time): global ans c[now] = 0 for e in edg[now]: if c[e]: if time == k: ans += 1 dfs(e, 1) else: ...
s387298159
p04008
u488401358
1589624994
Python
PyPy3 (2.4.0)
py
Runtime Error
420
86640
512
N,K=map(int,input().split()) a=list(map(int,input().split())) a=[a[i]-1 for i in range(N)] ans=int((a[0]!=0)) a[0]=0 depth=[-1 for i in range(N)] depth[0]=0 def dfs(v): if depth[v]!=-1: return depth[v] depth[v]=dfs(a[v])+1 return depth[v] for i in range(1,N): depth[i]=dfs(i) if K!=1: for i...
s914803608
p04008
u528388170
1586294140
Python
Python (3.4.3)
py
Runtime Error
17
2940
1189
#include<bits/stdc++.h> using namespace std; const int SIZE = 100001; priority_queue<pair<int, int>> D;//pair(depth, id)j int P[SIZE];//parent, depth vector<int> C[SIZE];//children set<int> S; void make_D(int id = 1, int depth = 0){ D.push(make_pair(depth, id)); for (int i = 0; i < C[id].size(); i++){ ...
s828945171
p04008
u638795007
1584759065
Python
Python (3.4.3)
py
Runtime Error
206
23660
3594
def examA(): A, B, C = LI() ans = min(A*B*(C%2),A*C*(B%2),B*C*(A%2)) print(ans) return def examB(): class segment_(): def __init__(self, A, n, segfunc): #####単位元######要設定0or1orinf self.ide_ele = inf #################### self.num = 1 << (n - 1)...
s422784900
p04008
u141610915
1584560794
Python
PyPy3 (2.4.0)
py
Runtime Error
190
38384
4380
import sys from collections import defaultdict as dd from collections import deque as dq input = sys.stdin.readline sys.setrecursionlimimt(10 ** 6) N, K = map(int, input().split()) a = list(map(int, input().split())) if K >= N - 1: print(int(a[0] != 1)) exit(0) res = 0 if a[0] != 1: a[0] = 1 res += 1 e = dd(set...
s503969334
p04008
u141610915
1584560751
Python
PyPy3 (2.4.0)
py
Runtime Error
1063
139156
4348
import sys from collections import defaultdict as dd from collections import deque as dq input = sys.stdin.readline N, K = map(int, input().split()) a = list(map(int, input().split())) if K >= N - 1: print(int(a[0] != 1)) exit(0) res = 0 if a[0] != 1: a[0] = 1 res += 1 e = dd(set) for i in range(N): e[a[i]].a...
s301392105
p04008
u693716675
1583624445
Python
Python (3.4.3)
py
Runtime Error
189
22892
493
#d tree n,k = [int(i) for i in input().split()] a = [int(i)-1 for i in input().split()] #this is directed tree so every node is not reached yet def dfs(u, d): change = 0 if d>k: d = 1 change += 1 for v in edges[u]: if u!=v: change += dfs(v, d+1) return change ...
s261641075
p04008
u693716675
1583624395
Python
Python (3.4.3)
py
Runtime Error
186
22896
510
#d tree n,k = [int(i) for i in input().split()] a = [int(i)-1 for i in input().split()] #this is directed tree so every node is not reached yet def dfs(u, d): change = 0 if d>k: d = 1 change += 1 for v in edges[u]: if u==v: continue change += dfs(v, d+1) ...
s245349810
p04008
u693716675
1583624173
Python
Python (3.4.3)
py
Runtime Error
184
22896
459
#d tree n,k = [int(i) for i in input().split()] a = [int(i)-1 for i in input().split()] #this is directed tree so every node is not reached yet def dfs(u, d): change = 0 if d>k: d = 1 change += 1 for v in edges[u]: change += dfs(v, d+1) return change cnt = 0 if a[0]!=0: ...
s670454131
p04008
u310678820
1572400112
Python
PyPy3 (2.4.0)
py
Runtime Error
422
83948
2346
class BIT: def __init__(self, n): self.N = n self.n = 1<<n.bit_length() self.data = [0] * (self.n + 1) self.num = 0#要素の個数(multisetの代用として使う場合のみ) def sum(self, i): s = 0 while i > 0: s += self.data[i] i -= i & -i return s def add...
s145677221
p04008
u102461423
1569053874
Python
Python (3.4.3)
py
Runtime Error
577
60900
1125
import sys readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 7) N,K = map(int,readline().split()) A = [int(x)-1 for x in readline().split()] desc_edge = [set() for _ in range(N)] parent = [0] * N for i,x in enumerate(A[1:],1): # 根から葉に向かう向きに辺を持つ desc_edge[x].add(i) p...
s356756873
p04008
u229621546
1555374201
Python
Python (3.4.3)
py
Runtime Error
190
22904
344
N,M = map(int,input().split()) L = list(map(int,input().split())) l = [[] for i in range(N)] ans = 0 if L[0] == 1 else 1 L[0] = 0 for i in range(1,len(L)): l[L[i] - 1].append(i) def search(ind,a): global ans if a > M: ans += 1 a = 0 if len(l[ind]) == 0: return for i in l[ind]: search(i,a+1)...
s226688517
p04008
u316386814
1553370889
Python
Python (3.4.3)
py
Runtime Error
596
143468
899
import sys sys.setrecursionlimit(10**7) INF = 10 ** 18 MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() de...
s558774156
p04008
u745087332
1551860939
Python
Python (3.4.3)
py
Runtime Error
277
29216
1197
# coding:utf-8 import sys from collections import defaultdict, deque INF = float('inf') MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): r...
s338050014
p04008
u884982181
1543722795
Python
PyPy3 (2.4.0)
py
Runtime Error
1069
206372
670
import sys sys.setrecursionlimit(200000) n,k = map(int,input().split()) a = list(map(int,input().split())) ans = 0 if a[0] != 1: a[0] = 1 ans += 1 b = [[]for i in range(n)] for i in range(n): b[a[i]-1].append(i) b[0].remove(0) huka = 0 kyo = [float("inf")] * n def dfs(x,y): kyo[x] = y for i in b[x]: dfs(i...
s469457677
p04008
u884982181
1543720565
Python
PyPy3 (2.4.0)
py
Runtime Error
556
103024
391
n,k = map(int,input().split()) a = list(map(int,input().split())) ans = 0 if a[0] != 1: a[0] = 1 ans += 1 b = [[]for i in range(n)] for i in range(n): b[a[i]-1].append(i) b[0].remove(0) kyo = [float("inf")] * n def dfs(x,y,z): if y>k and z == 0: y= 0 z = 1 if y > k-1 and z == 1: y = 0 kyo[x] = y...
s048039210
p04011
u910358825
1601287319
Python
Python (3.8.2)
py
Runtime Error
23
8968
93
n,k,x,y=[int(input()) for i in range(n)] if k<=x: print(n*k) else: print(k*x+(n-k)*y)
s629893841
p04011
u401183062
1601226552
Python
Python (3.8.2)
py
Runtime Error
23
8940
182
n, k, price, special = map(int, input().split()) result = 0 for i in range(n): if i < k: result += price else: result += special
s292877404
p04011
u401183062
1601226494
Python
Python (3.8.2)
py
Runtime Error
27
9000
205
n, k, price, special = map(int, input().split()) result = 0 for i in range(n): if i < k: result += price else: result += special print(result)
s028146518
p04011
u401183062
1601226450
Python
Python (3.8.2)
py
Runtime Error
25
9064
271
def iroha(): n, k, price, special = map(int, input().split()) result = 0 for i in range(n): if i < k: result += price else: result += special print(result) if __name__ == "__main__": iroha()
s736676162
p04011
u401183062
1601226308
Python
Python (3.8.2)
py
Runtime Error
24
9080
269
def iroha(): n, k, price, special = map(int, input().split()) result = 0 for i in range(n): if i < k: result += price else: result += special print(result) if __name__ == "__main__": iroha()
s915700251
p04011
u401183062
1601226264
Python
Python (3.8.2)
py
Runtime Error
25
8944
199
n, k, price, special = map(int, input().split()) result = 0 for i in range(n): if i < k: result += price else: result += special print(result)
s437177764
p04011
u847033024
1599987880
Python
Python (3.8.2)
py
Runtime Error
23
8956
145
a = int(input()) b = int(input()) c = int(input()) d = int(input()) x = a - b y = b * c z = x * d if a > b: print(y + z) else: print(y)
s629950488
p04011
u231198419
1599333978
Python
Python (3.8.2)
py
Runtime Error
26
8800
89
N,K,X,Y=[int(input()) for i in range(4)] if(K>N): N=K else: Z=K*X+(N-K)*Y print(Z)
s608595389
p04011
u546132222
1599101840
Python
Python (3.8.2)
py
Runtime Error
28
9160
340
# abc044_a # https://atcoder.jp/contests/abc044/tasks/abc044_a # 最初のK泊までは、X円 # K+1泊目以降は、Y円 # N泊連続で宿泊した際の宿泊費 # 入力 n, k, x, y = map(int, input().split()) # 処理 # x円とy円 if n > k: answer = k * x + (n - k) * y # x円のみ else: answer = n * x print(answer)
s493889273
p04011
u147912476
1598621439
Python
Python (3.8.2)
py
Runtime Error
22
9032
141
k, x, y, n = map(int, input().split()) if n <= k: print(n * x) else: print(k*x+(n-k)*y) # 演算子の左右に空白を入れる!
s806870973
p04011
u668271522
1598589442
Python
Python (3.8.2)
py
Runtime Error
24
9096
85
N,K,X,Y= map(int, input().split()) yen1 = K * X yen2 = (N - K) * Y print(yen1 + yen2)
s381321669
p04011
u003505857
1598532614
Python
Python (3.8.2)
py
Runtime Error
27
9020
120
N, K, X, Y = map(int, input().split()) a = N * X b = K * X + (N - K) * Y if N <= K: print(a) else: print(b)
s055856568
p04011
u003505857
1598532518
Python
Python (3.8.2)
py
Runtime Error
27
9148
118
N, K, X, Y = map(int, input().split()) a = N * X b = K * X + (N - K) * Y if N < K: print(a) else: print(b)
s536662385
p04011
u808569469
1598404118
Python
Python (3.8.2)
py
Runtime Error
25
9084
104
N, K, X, Y = map(int, input().split()) if N <= K: print(N * X) else: print(K * X + (N - K) * Y)
s174070998
p04011
u808569469
1598403962
Python
Python (3.8.2)
py
Runtime Error
24
8960
104
n, k, x, y = map(int, input().split()) if n <= k: print(n * x) else: print(k * x + (n - k) * y)
s788929143
p04011
u808569469
1598403416
Python
Python (3.8.2)
py
Runtime Error
26
9160
110
n, k, x, y = map(int, input().split()) if n <= k: print(n * x) else: print(k * x + (n - k) * y)
s601660667
p04011
u808569469
1598402843
Python
Python (3.8.2)
py
Runtime Error
23
9060
105
n, k, x, y = map(int, input().split()) if n <= k: print(k * x) else: print(k * x + (n - k) * y)
s229333446
p04011
u003505857
1598365512
Python
Python (3.8.2)
py
Runtime Error
26
9156
107
N, K, X, Y, = map(int, input().split()) if N <= K: print(N * X) else: print(K * X + (N - K) * Y)
s242513630
p04011
u003505857
1598365369
Python
Python (3.8.2)
py
Runtime Error
27
9148
148
N, K, X, Y, = map(int, input().split()) if N <= K: answer = N * X print(answer) else: answer = K * X + (N - K) * Y print(answer)