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
s279527287
p03971
u062691227
1592899376
Python
Python (3.8.2)
py
Runtime Error
28
9144
340
x, s = *open(0), print(x) print(s) n, a, b = map(int, x.rstrip.split()) p = 0 wp = 0 for char in s: if char == 'c' or p >= a+b: print('No') continue if char == 'a': p += 1 print('Yes') continue if wp < b: p += 1 wp += 1 print('Yes') else: print('No')
s485424953
p03971
u829416877
1592481499
Python
Python (3.4.3)
py
Runtime Error
17
2940
354
N,A,B = map(int, input().split()) S = input().split() s=[] for i in S: s.append(i) list=[] H = list.count('b') for i in range(N): if s[i] == 'c' print('No') elif s[i] =='a' and len(list) <= A+B: print('Yes') list.append(a) elif s[i] =='a': print('No') elif len(list) <= A+B and H <= B: print('Yes') else: print('No')
s876423145
p03971
u526131148
1592370447
Python
Python (3.4.3)
py
Runtime Error
17
3188
431
N, A, B = map(int, input().split()) S = str(input()) total = 0 kaigai = 0 for i in range(0, len(S)): if L[i] == 'a': if total < A+B: print('Yes') total += 1 else: print('No') elif L[i] == 'b': if total < A+B & kaigai <B: print('Yes') total += 1 kaigai += 1 else: print('No') else: print('No')
s367798773
p03971
u579469974
1592359592
Python
PyPy3 (2.4.0)
py
Runtime Error
162
38256
391
def main(): n,a,b=mi() s=input() nover=0 tot=0 for i in range(n): if tot<a+b: if s[i]=='a': print('Yes') tot+=1 elif s[i]=='b' and nover<b: print('Yes') nover+=1 tot+=1 else: print('No') else: print('No') main()
s062876582
p03971
u579469974
1592359491
Python
PyPy3 (2.4.0)
py
Runtime Error
180
38512
413
def main(): n,a,b=mi() s=list(input()) nover=0 tot=0 for i in range(n): if tot<a+b: if s[i]=='a': print('Yes') tot+=1 elif s[i]=='b' and nover<b: print('Yes') nover+=1 tot+=1 else: print('No') else: print('No') main()
s255065078
p03971
u232873434
1592315611
Python
PyPy3 (2.4.0)
py
Runtime Error
173
38384
402
import numpy as np N,A,B = map(int,input().split()) S = input() total = A+B for i in range(N): if S[i]=='c': print('No') elif total>0: if S[i] == 'a': print('Yes') total = total-1 elif S[i] =='b' and B>0: print('Yes') total = total-1 B = B-1 else: print('No') else: print('No')
s468150000
p03971
u363146889
1591650342
Python
PyPy3 (2.4.0)
py
Runtime Error
372
72148
775
# -*- coding: utf-8 -*- ## Library import sys from fractions import gcd import math from math import ceil,floor import collections from collections import Counter ## input # n=int(input()) # A,B,C,D=map(int, input().split()) # string = input() # yoko = list(map(int, input().split())) # tate = [int(input()) for _ in range(N)] # N, M = map(int,input().split()) # P = [list(map(int,input().split())) for i in range(M)] N,A,B=map(int, input().split()) S = input() tmp1 = 0 tmp2 = 0 for i in range(0,N): if tmp1 < A+B: if S[i] == "a": tmp1 += 1 print("Yes") elif S[i] == "b" & tmp2 < B: tmp1 += 1 tmp2 += 1 print("Yes") else: print("No") else: print("No")
s198481969
p03971
u441246928
1591241744
Python
Python (3.4.3)
py
Runtime Error
18
3064
399
N,A,B = map(int,input().split()) S = input() cnt = 0 bcnt = 1 for s in S : if s =='a' : if A + B > cnt : print('Yes') cnt += 1 else : print('No') elif s == 'b' if A + B > cnt and B => bcnt : print('Yes') bcnt += 1 cnt += 1 else : print('No') else : print('No')
s250984732
p03971
u441246928
1591241710
Python
Python (3.4.3)
py
Runtime Error
17
2940
398
N,A,B = map(int,input().split()) S = input() cnt = 0 bcnt = 1 for s in : if s =='a' : if A + B > cnt : print('Yes') cnt += 1 else : print('No') elif s == 'b' if A + B > cnt and B => bcnt : print('Yes') bcnt += 1 cnt += 1 else : print('No') else : print('No')
s497784979
p03971
u441246928
1591241677
Python
Python (3.4.3)
py
Runtime Error
17
2940
405
N,A,B = map(int,input().split()) S = list(input()) cnt = 0 bcnt = 1 for s in S : if s =='a' : if A + B > cnt : print('Yes') cnt += 1 else : print('No') elif s == 'b' if A + B > cnt and B => bcnt : print('Yes') bcnt += 1 cnt += 1 else : print('No') else : print('No')
s370951560
p03971
u441246928
1591241424
Python
Python (3.4.3)
py
Runtime Error
17
2940
413
N,A,B = map(int,input().split()) S = list(input()) cnt = 0 bcnt = 1 for i in S : if S[i] == 'a' : if A + B > cnt : print('Yes') cnt += 1 else : print('No') elif S[i] == 'b' if A + B > cnt and B => bcnt : print('Yes') bcnt += 1 cnt += 1 else : print('No') else : print('No')
s160932486
p03971
u674588203
1591240898
Python
PyPy3 (2.4.0)
py
Runtime Error
169
38384
378
N,A,B=map(int,input(),()) S=input() nowA=0 nowB=0 for s in S: if s=='c': print('No') elif s=='a': if nowA+nowB<=A+B: nowA+=1 print('Yes') else: print('No') else: if nowA+nowB<=A+B and nowB<=B: nowB+=1 print('Yes') nowB+=1 else: print('No')
s005778414
p03971
u441246928
1591240828
Python
Python (3.4.3)
py
Runtime Error
17
2940
411
N,A,B = map(int,input.split()) S = list(input()) cnt = 0 bcnt = 1 for i in S : if S[i] == 'a' : if A + B > cnt : print('Yes') cnt += 1 else : print('No') elif S[i] == 'b' if A + B > cnt and B => bcnt : print('Yes') bcnt += 1 cnt += 1 else : print('No') else : print('No')
s181631843
p03971
u364386647
1591105407
Python
Python (3.4.3)
py
Runtime Error
17
3064
571
def resolve(): N, A, B = list(map(int, input().split())) S = str(input()) num = 0 foreignnum = 1 for i in range(N): if S[i] == 'a': if (num < A + B): num += 1 print('Yes') else: print('No') if S[i] == 'b': if (num < A + B) and (foreignnum <= B): num += 1 foreignnum += 1 print('Yes') else: print('No') if S[i] == 'c': print('No') return resolve()
s427898949
p03971
u791110052
1591067563
Python
Python (3.4.3)
py
Runtime Error
17
2940
250
j = 0 for n in s: if n == "a": if i + j < a + b: i += 1 print("Yes") else: print("No") elif n == "b": if (i + j < a + b) and j < b: j += 1 print("Yes") else: print("No") else: print("No")
s414909762
p03971
u581403769
1590710707
Python
Python (3.4.3)
py
Runtime Error
17
2940
429
n, a, b = map(int, input().split()) s = input() all = list(s) count = 0 count_b = 0 for i in all: if i == 'a': if count <= a + b: print('yes') count += 1 else: print('no') if i == 'b': if count <= a + b and count_b <= b print('yes') count += 1 count_b += 1 else: print('no') else: print('no')
s737339075
p03971
u810288681
1590533911
Python
Python (3.4.3)
py
Runtime Error
17
3060
99
import math n = int(input()) x1 = math.ceil(n/1.08) print(':(' if math.floor(x1*1.08) != n else x1)
s161386873
p03971
u238940874
1589490911
Python
Python (3.4.3)
py
Runtime Error
18
3060
260
s=input() cnt=0 for i in range(n): if s[i] == 'a' and cnt < a+b: print('Yes') cnt+=1 elif s[i] == 'b' and cnt < a+b and i+1 <=b: print('Yes') cnt+=1 elif s[i] == 'c': print('No') else: print('No')
s574355924
p03971
u198930868
1588797761
Python
Python (3.4.3)
py
Runtime Error
17
2940
314
N,A,B = map(int,input().split()) student = input() passp = 0 passb = 0 for s in student: if s == "a": if passp < (A+B): passp += 1 print("Yes") else: print("No") elif s == "b": if passp < (A+B) and passb < B: passp += 1 passb += 1 print("Yes") else: print("No") else: print("No")
s475586473
p03971
u198930868
1588797675
Python
Python (3.4.3)
py
Runtime Error
17
2940
314
N,A,B = map(int,input().split()) student = input() passp = 0 passb = 0 for s in student: if s == "a": if passp < (A+B): passp += 1 print("YES") else: print("NO") elif s == "b": if passp < (A+B) and passb < B: passp += 1 passb += 1 print("YES") else: print("NO") else: print("NO")
s465781634
p03971
u827306875
1588782119
Python
Python (3.4.3)
py
Runtime Error
17
2940
367
N, A, B = input().split() s = [str(x) for x in input().split()] count = 0 sb = 0 for i in range(len(s)): if s[i] == a: if count <= A+B: print('Yes') count +=1 else: print('No') elif s[i] == b: if count <= A+B && sb <= B: print('Yes') count += 1 sb += 1 else: print('No') else: print('No')
s628022227
p03971
u708890186
1588562842
Python
Python (3.4.3)
py
Runtime Error
18
3188
301
N,A,B=map(int,input().split()) S=input() cnta=0 for i in range(N): if S[i]==a: if cnta<A+B: print("Yes") cnta+=1 else: print("No") elif S[i]==b: if (cnta < A+B) and (i+1 <= B): print("Yes") cnta+=1 else: print("No") else: print("No")
s228863727
p03971
u708890186
1588562640
Python
Python (3.4.3)
py
Runtime Error
18
2940
286
N,A,B=map(int,input().split()) S=input() cnta=0 cntb=0 for i in range(N): if S[i]==a: if cnta<A: print("Yes") elsse: print("No") cnta+=1 elif S[i]==b: if cntb+cnta < A+B: print("Yes") elsse: print("No") cntb+=1 else: print("No")
s570213391
p03971
u746154235
1588358358
Python
Python (3.4.3)
py
Runtime Error
18
3188
306
N,A,B=map(int, input().split()) S=int(input().split()) cntA=0 cntB=0 for s in S: if s == 'c': print('No') continue if s == 'a' and (cntA+cntB) < A+B: print('Yes') cntA +=1 elif (s == 'b') and ((cntA+cntB) < A+B) and (cntB < B): print('Yes') cntB +=1 else: print('No')
s436177440
p03971
u746154235
1588358312
Python
Python (3.4.3)
py
Runtime Error
17
3188
291
N,A,B=map(int, input().split()) S=int(input().split()) for s in S: if s == 'c': print('No') continue if s == 'a' and (cntA+cntB) < A+B: print('Yes') cntA +=1 elif (s == 'b') and ((cntA+cntB) < A+B) and (cntB < B): print('Yes') cntB +=1 else: print('No')
s575288417
p03971
u425762225
1588089966
Python
PyPy3 (2.4.0)
py
Runtime Error
182
39152
325
N, A, B = map(int,input().split()) S = input() a_counter, b_counter = 0 while S != "": s = S[0] if s == "a" and a_counter + b_counter <=a+b: a_counter += 1 print("Yes") elif s == "b" and b_counter <= b and a_counter + b_counter <=a+b: b_counter += 1 print("Yes") else: print("No") S = S[1:]
s086284844
p03971
u023751250
1588040502
Python
Python (3.4.3)
py
Runtime Error
17
2940
341
n,in,out=map(int,input().split()) b=input() kokunai=0 kaigai=0 for i in range(n): if(b[i]=='c'): print('No') else if(b[i]=='a'): if(kokunai+kaigai>=in+out): print('No') else: kokunai=kokunai+1 print('Yes') else: if(kokunai+kaigai>=in+put or kaigai>=out): print('No') else: print('Yes')
s095317001
p03971
u629607744
1587779303
Python
Python (3.4.3)
py
Runtime Error
100
4600
209
n,A,B=map(int,input().split()) s=list(input()) cnt=0 cnt_b=0 for i in range(n): if s[i]=='a' and cnt<a+b: print('Yes') cnt+=1 elif s[i]=='b' and cnt<A+B and cnt_b<=B: print('Yes') else: print('No')
s006344165
p03971
u629607744
1587779214
Python
Python (3.4.3)
py
Runtime Error
17
2940
274
n,A,B=map(int,input().split()) s=list(input()) cnt=0 cnt_b=0 for i in range(n): if s[i]=='a' and cnt<a+b: print('Yes') cnt+=1 else: print('No') elif s[i]=='b' and cnt<A+B and cnt_b<=B: print('Yes') else: print('No') elif s[i]=='c': print('No') cnt_c+=1
s767659482
p03971
u331997680
1587503646
Python
Python (3.4.3)
py
Runtime Error
30
3956
304
N, A, B = map(int, input().split()) C = input() D = [C[i:i+1] for i in range(N)] AA = 0 BB = 0 for i in(D): if D[i] == 'c': print('No') elif D[i] =='a' and A+B > AA+BB: print('Yes') AA += 1 elif D[i] =='a' and A+B > AA+BB and BB < B: print('Yes') BB += 1 else: print('No')
s564197367
p03971
u869265610
1587335847
Python
Python (3.4.3)
py
Runtime Error
17
2940
274
N,A,B=map(int,input().split()) S=list(map(input().split())) sin=0 cos=0 for i in range(S) if S.pop(i)='a'or'b': sin+=1 if S.pop(i)='b': cos+=1 print("Yes" if S.pop(i)='a' and sin<A+B: "Yes" elif S.pop(i)='b' and B<=cos and sin<A+B: else "No")
s849056399
p03971
u869265610
1587335718
Python
Python (3.4.3)
py
Runtime Error
17
3064
309
N,A,B=map(int,input().split()) S=list(map(input().split())) sin=0 cos=0 K=list.count("a") G=list.count("b") for i in range(S) if S.pop(i)='a'or'b': sin+=1 if S.pop(i)='b': cos+=1 print("Yes" if S.pop(i)='a' and sin<K+G: "Yes" elif s.pop(i)='b' and G<=cos and sin<K+G: else "No")
s234081684
p03971
u502200133
1587333479
Python
Python (3.4.3)
py
Runtime Error
93
4016
246
p = 0 n, a, b = map(int, input().split()) for i in input(): if i == "a" and p < a+b: p += 1 print("Yes") elif i == "b" and p < a+b and f < b: f += 1 p += 1 print("Yes") else: print("No")
s399099567
p03971
u545644875
1587249579
Python
Python (3.4.3)
py
Runtime Error
120
4708
989
li = list(map(int,input().split())) s=list(input()) cnt = 0 b = 0 for i in s: if i == "a": if cnt < li[1] + li[2]: cnt += 1 print("Yes") else: print("No") elif i == "b": b += 1 if cnt < li[1] + li[2]: if b <= li[2]: cnt += 1 print("Yes") else: print("No") else: print("No") else: #cnt -= 1 print("No") #print(a) li = list(map(int,input().split())) s=list(input()) cnt = 0 b = 0 for i in s: if i == "a": if cnt < li[1] + li[2]: cnt += 1 print("Yes") else: print("No") elif i == "b": b += 1 if cnt < li[1] + li[2]: if b <= li[2]: cnt += 1 print("Yes") else: print("No") else: print("No") else: #cnt -= 1 print("No")
s800871878
p03971
u545644875
1587248627
Python
Python (3.4.3)
py
Runtime Error
18
2940
567
x = list(map(int, input().split())) s = list(input()) y = len(s) rank = 0 frank = 0 for i in s: if i == "a": if rank <= x[1] + x[2]: rank += 1 print("Yes") else: print("No") elif i == "b": if rank <= x[1] + x[2]: rank += 1 if frank <= x[2]: frank += 1 print("Yes") else: print("No") else: print("No") else: print("No")
s265020038
p03971
u545644875
1587248423
Python
Python (3.4.3)
py
Runtime Error
18
3064
592
x = list(map(int, input().split())) s = list(input()) y = len(s) rank = 0 frank = 0 for i in s: if i == "a": if rank <= x[1] + x[2]: rank += 1 print("Yes") else: print("No") elif i == "b": if rank <= x[1] + x[2]: rank += 1 if frank <= x[2]: frank += 1 print("Yes") else: print("No") else: print("No") else: print("No")
s520936512
p03971
u545644875
1587246557
Python
Python (3.4.3)
py
Runtime Error
17
2940
508
x = list(map(int, input().split())) s = list(input()) y = len(s) rank = 0 frank = 0 for i in s: if i == "c": print("NO") elif i == "b": if rank =< x[1] + x[2] and frank =< x[2]: rank += 1 frank += 1 print("YES") else: print("NO") else: if rank =< x[1] + x[2]: rank += 1 print("YES") else: print("NO")
s710830408
p03971
u274635633
1586746937
Python
Python (3.4.3)
py
Runtime Error
17
2940
236
n,a,b=map(int,input().split()) s=input() all=a+b in=b for i in range(n): if all==0: print('No') elif s[i]=='a': print('Yes') all-=1 elif s[i]=='b' and in>0: print('Yes') all-=1 in-=1 else: print('No')
s581868409
p03971
u251779460
1586738618
Python
Python (3.4.3)
py
Runtime Error
17
2940
824
#include <bits/stdc++.h> using namespace std; #define SORT(a) sort((a).begin(), (a).end()) #define RSORT(a) reverse((a).begin(), (a).end()) #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; const long long INF = 1LL << 60; // const int INF=1010101010; using Graph = vector<vector<int>>; int main() { int n, a, b; string s; cin >> n >> a >> b >> s; int cnt = 0; //予選通過確定者の人数 int kaigai = 0; rep(i, n) { if (cnt + 1 <= a + b) { if (s[i] == 'a') { cnt++; cout << "Yes" << endl; } else if (s[i] == 'b') { kaigai++; if (kaigai <= b) { cout << "Yes" << endl; cnt++; } else cout << "No" << endl; } else { cout << "No" << endl; } } else cout << "No" << endl; } }
s333567630
p03971
u089142196
1586712613
Python
Python (3.4.3)
py
Runtime Error
17
2940
214
N,A,B = map(int,input().split()) S=input() pas=0 kai=0 for num in S: if num=="a": if pas<A+B: pas +=1 print("Yes") else: print("No") elif num=="b": if pas<A+B and : pas +=1
s144110919
p03971
u857460786
1586665536
Python
Python (3.4.3)
py
Runtime Error
17
2940
441
# coding: utf-8 As = list(input().rstrip().split(" ")) N = int(As[0]) A = int(As[1]) B = int(As[2]) S = input() cnt = 1 for i in range(N): if S[i] == "c": print("No") elif S[i] == "a": if cnt < A+B: print("Yes") cnt +=1 else: print("No") elif S[i] == "b": if cnt < B: print("Yes") cnt +=1 else: print("No")
s314282538
p03971
u857460786
1586665481
Python
Python (3.4.3)
py
Runtime Error
17
2940
393
# coding: utf-8 N,A,B=list(map(int,input().split())) S = input() cnt = 1 for i in range(N): if S[i] == "c": print("No") elif S[i] == "a": if cnt < A+B: print("Yes") cnt +=1 else: print("No") elif S[i] == "b": if cnt < B: print("Yes") cnt +=1 else: print("No")
s287877101
p03971
u036914910
1586665049
Python
Python (3.4.3)
py
Runtime Error
17
2940
223
or i in range(N) : if (S[i] == 'a') and (c < A + B) : print('Yes') c += 1 elif S[i] == 'b' and (c < A + B) and b < B: print('Yes') b += 1 c += 1 else : print('No')
s844036293
p03971
u857460786
1586664922
Python
Python (3.4.3)
py
Runtime Error
17
3188
371
# coding: utf-8 As = list(input().rstrip().split(" ")) N = As[0] A = As[1] B = As[2] S = input() for i in range(N): if S[i] == "c": print("No") elif S[i] == "a": if i < A+B: print("Yes") else: print("No") elif S[i] == "b": if i < B: print("Yes") else: print("No")
s110365654
p03971
u857460786
1586664771
Python
Python (3.4.3)
py
Runtime Error
18
3188
395
# coding: utf-8 pre_list = list(input().rstrip().split(" ")) N = pre_list[0] A = pre_list[1] N = pre_list[2] S = input() for i in range(N): if S[i] == "c": print("No") elif S[i] == "a": if i < A+B: print("Yes") else: print("No") elif S[i] == "b": if i < B: print("Yes") else: print("No")
s148039318
p03971
u857460786
1586664526
Python
Python (3.4.3)
py
Runtime Error
18
3064
393
# coding: utf-8 pre_list = list(input().rstrip().split("")) N = pre_list[0] A = pre_list[1] N = pre_list[2] S = input() for i in range(N): if S[i] == "c": print("No") elif S[i] == "a": if i < A+B: print("Yes") else: print("No") elif S[i] == "b": if i < B: print("Yes") else: print("No")
s170720901
p03971
u857460786
1586664296
Python
Python (3.4.3)
py
Runtime Error
17
2940
338
# coding: utf-8 N,A,B=list(map(int,input().split())) S = input() for i in range(N): if S[i] == "c": print("No") elif S[i] == "a": if i < A+B: print("Yes") else: print("No") elif S[i] == "b": if i < B: print("Yes") else: print("No")
s173669969
p03971
u735335967
1586638444
Python
Python (3.4.3)
py
Runtime Error
17
3060
289
n, a, b = map(int, input().split()) b_cnt = 0 a_cnt = 0 for i in range(n): if s[i] == "a" and (a_cnt+b_cnt) < a+b: a_cnt += 1 print("Yes") elif s[i] == "b" and (a_cnt+b_cnt) < a+b and b_cnt < b: b_cnt += 1 print("Yes") else: print("No")
s774043274
p03971
u735335967
1586638388
Python
Python (3.4.3)
py
Runtime Error
17
3060
303
n, a, b = map(int, input().split()) print(len(s)) b_cnt = 0 a_cnt = 0 for i in range(n): if s[i] == "a" and (a_cnt+b_cnt) < a+b: a_cnt += 1 print("Yes") elif s[i] == "b" and (a_cnt+b_cnt) < a+b and b_cnt < b: b_cnt += 1 print("Yes") else: print("No")
s076813627
p03971
u056358163
1586634303
Python
Python (3.4.3)
py
Runtime Error
17
3060
473
N, A, B = a,b=map(int, input().split()) S = input() qualified = 0 qualified_foreign = 0. for s in S: if s == 'c': print('No') elif s == 'a': if qualified < A + B: print('Yes') qualified += 1 else: print('No') else: if (qualified < A + B) & (qualified_foreign < B): print('Yes') qualified += 1 qualified_foreign += 1 else: print('No')
s995824836
p03971
u113971909
1583667888
Python
Python (3.4.3)
py
Runtime Error
17
3188
300
n,a,b=map(int,input().split()) cab,cb=0,0 for i in range(n): s=input() if s=='c': print('No') if s=='a': if cab<a+b: print('Yes') cab+=1 else: print('No') if s=='b': if cab<a+b and cb<b: print('Yes') cab+=1 cb+=1 else: print('No')
s516981620
p03971
u291988695
1581359490
Python
Python (3.4.3)
py
Runtime Error
24
3956
258
n,a,b=map(int,input().split()) bs=1 a=[""]*n s=input() for k in range(n): if s[k]!="c": k<=a+b-1 if s[k]=="a": a[k]="Yes" else: if bs<=b: bs+=1 a[k]="Yes" else: a[k]="No" else: a[k]="No" print(*a)
s294532946
p03971
u969190727
1558047651
Python
Python (3.4.3)
py
Runtime Error
118
4016
290
n,a,b=map(int,input().split()) s=input() pa,pb=0,0 for i in range(n): if s[i]=='a': pa+=1 if pa+prb<=a+b: print('Yes') else: print('No') elif s[i]=='b': pb+=1 if pa+pb<=a+b and pb<=b: print('Yes') else: print('No') else: print('No')
s805662681
p03971
u426108351
1554227177
Python
Python (3.4.3)
py
Runtime Error
18
3188
223
N, A, B = map(int, input().split()) S = input() a = 0 b = 0 for i in range(S): if S[i] == 'a' and a+b < A+B: a += 1 print('Yes') elif S[i] == 'b' and a+b < A+B and b < B: print('Yes') else: print('No')
s158119341
p03971
u118642796
1553574972
Python
Python (3.4.3)
py
Runtime Error
18
3188
387
N,A,B = map(int,input().split()) S = input() win = 0 abr = 0 for c in S: if c == a: if win<A+B: print("Yes") win += 1 else: print("No") elif c == b: if win < A+B and abr <= B: print("Yes") win += 1 abr += 1 else: print("No") else: print("No")
s519280081
p03971
u543954314
1552236037
Python
Python (3.4.3)
py
Runtime Error
18
3188
240
n, a, b = map(int, input().split()) s = input() cnt = a+b fc = b for i in range(n): if s[n] == 'a' and cnt: print("Yes") cnt -= 1 elif s[n] == 'b' and cnt and fc: print("Yes") cnt -= 1 fc -= 1 else: print("No")
s148224537
p03971
u846150137
1537068461
Python
Python (3.4.3)
py
Runtime Error
17
3064
373
I = lambda: [int(i) for i in input().split()] n,k=I() a=I()[::-1] a.append(0) b=[] p=1 for i in range(n): if i==0: b+=[a[i] + a[i] * (p + 1)**2 + k ] elif a[i] * 2 ** 2 + a[i] * (p + 1)**2 + a[i] + k > a[i] * (p + 1 + 1)**2 : b+=[p*a[i] * (p + 1 + 1)**2 - p * a[i] * (p + 1)**2] p+=1 else: b+=[a[i] * 2 **2 + a[i] + k] p=1 print(sum(b) +k*n)
s846812483
p03971
u333945892
1536111047
Python
Python (3.4.3)
py
Runtime Error
17
3064
347
N,A,B = map(int,list(input())) S = input() tmp = 0 tmpf = 0 for i in range(1,N+1): s = S[i] if s == "a": if tmp <= A+B: print("Yes") tmp +=1 else: print("No") elif s == "b": if tmp <= A+B and tmpf <=B: print("Yes") tmp +=1 tmpf += 1 else: print("No") else: print("No")
s649258398
p03971
u941884460
1526047060
Python
Python (3.4.3)
py
Runtime Error
17
2940
353
N,A,B=map(int,input().split()) s = input().rstrip() count = 0 countB = 0 for i in range(N): if A+B <= count: print('No') else: if s[i] == 'a': print('Yes') count += 1 elif s[i] =='b'" if countB <= B: print('Yes') countB += 1 count += 1 else: print('No') else: print('No')
s346713629
p03971
u582243208
1476310914
Python
Python (3.4.3)
py
Runtime Error
25
3064
256
n,a,b=map(int,input().split()) s=input() for i in s: if a+b>0: if i=="a": a-=1 print("Yes") continue elif i=="b" and b>0: b-=1 print("Yes") continue print("No")
s252063025
p03971
u619384481
1476149404
Python
Python (2.7.6)
py
Runtime Error
25
6660
323
init_input=map(int, raw_input().split()) mem=raw_input() mem_list=list(mem) man=init_input[0] jap=init_input[1] ove=init_input[2] jas=0 ovs=0 for i in range(man): if mem==a and jas+ovs<jap+ove: jap+=1 print "Yes" elif mem==b and jas+ovs<jap+ove and ovs<ove: ovs+=1 print "Yes" else: print "No"
s475840930
p03971
u279903174
1476120898
Python
Python (2.7.6)
py
Runtime Error
17
2948
447
args = list(map(lambda x: int(x), raw_input().split())) N = args[0] A = args[1] B = args[2] s = input() a = 0 b = 0 for i in range(0, len(s)): if s[i] == 'a': if a + b < A + B: a = a + 1 print('Yes') else: print('No') elif s[i] == 'b': if a + b < A + B and b < B: b = b + 1 print('Yes') else: print('No') else: print('No')
s100043436
p03971
u279903174
1476120709
Python
Python (3.4.3)
py
Runtime Error
22
3064
449
args = list(map(lambda x: int(x), input().split())) N = args[0] A = args[1] B = args[2] s = input() a = 0 b = 0 for i in range(0, len(s)): if s[i] == 'a': if a + b < A + B: a = a + 1 print('Yes') else: print('No') elif s[i] == 'b': if a + b < A + B and b < B: b = b + 1 print('Yes') else: print('No') else: print('No')
s800130309
p03971
u279903174
1476120556
Python
Python (2.7.6)
py
Runtime Error
15
2568
449
args = list(map(lambda x: int(x), input().split())) N = args[0] A = args[1] B = args[2] s = input() a = 0 b = 0 for i in range(0, len(s)): if s[i] == 'a': if a + b < A + B: a = a + 1 print('Yes') else: print('No') elif s[i] == 'b': if a + b < A + B and b < B: b = b + 1 print('Yes') else: print('No') else: print('No')
s545548417
p03971
u835464975
1476120045
Python
Python (2.7.6)
py
Runtime Error
24
2820
373
# -*- coding: utf-8 -*- input_line_1 = raw_input() fields = input_line_1.split() N = fields[0] A = fields[1] B = fields[2] T = A + B all = raw_input() for every in all: if every == 'c': print 'No' elif every == 'a': if T > 0: T = T - 1 print 'Yes' else: print 'No' else: if T > 0 and B > 0: T = T - 1 B = B - 1 print 'Yes' else: print 'No'
s321420707
p03971
u835464975
1476119849
Python
Python (2.7.6)
py
Runtime Error
16
2568
376
# -*- coding: utf-8 -*- input_line_1 = raw_input() fields = input_line_1.split() N = fields[0] A = fields[1] B = fields[2] T = A + B all = raw_input() for every in all: if every == 'c': print 'No' else if every == 'a': if T > 0: T = T - 1 print 'Yes' else: print 'No' else: if T > 0 and B > 0: T = T - 1 B = B - 1 print 'Yes' else: print 'No'
s539784697
p03971
u664481257
1476119834
Python
Python (3.4.3)
py
Runtime Error
44
3784
1301
# -*- coding: utf-8 -*- # !/usr/bin/env python # vim: set fileencoding=utf-8 : """ # # Author: Noname # URL: https://github.com/pettan0818 # License: MIT License # Created: 2016-10-10 # # Usage # """ def read_value(): first_line = input() status = first_line.split(" ") num_of_contestant = status[0] basis = status[1] oversea_limit = status[2] second_line = input() rank_str = second_line return [num_of_contestant, basis, oversea_limit, rank_str] def check_japan(rank, basis, oversea_limit): if rank < basis + oversea_limit: return "Yes" else: return "No" def check_overseas(rank, oversea_rank, basis, oversea_limit): if rank < basis + oversea_limit and oversea_rank < oversea_limit: return "Yes" else: return "No" if __name__ == "__main__": input_items = read_value() basis = input_items[1] oversea_limit = input_items[2] rank_str = input_items[3] oversea_rank = 0 for rank, type in enumerate(rank_str): if type == "a": print(check_japan(rank, basis, oversea_limit)) if type == "b": oversea_rankt += 1 print(check_overseas(rank, oversea_rank, basis, oversea_limit)) if type == "c": print("No")
s377129417
p03972
u417212867
1600217931
Python
PyPy3 (7.3.0)
py
Runtime Error
302
87652
407
w, h = list(map(int, input().split())) xs = [int(input()) for _ in range(w)] ys = [int(input()) for _ in range(h)] x_cnt = w + 1 y_cnt = h + 1 i = 0 j = 0 xs.sort() ys.sort() ans = 0 while i < len(xs) or j < len(ys): if i >= len(xs) or ys[j] < xs[i]: ans += x_cnt * ys[j] j += 1 y_cnt -= 1 else: ans += y_cnt * xs[i] i += 1 x_cnt -= 1 print(ans)
s439050663
p03972
u707124227
1595691855
Python
Python (3.8.2)
py
Runtime Error
342
17344
274
w,h=map(int,input().split()) p=[int(input()) for _ in range(w)] q=[int(input()) for _ in range(h)] p.sort(reverse=True) q.sort(reverse=True) ans=0 c,r=w+1,h+1 while p or q: if not p or p[-1]>q[-1]: ans+=q.pop()*c r-=1 else: ans+=p.pop()*r c-=1 print(ans)
s052801937
p03972
u366541443
1588622443
Python
PyPy3 (2.4.0)
py
Runtime Error
944
68056
623
w,h = list(map(int, input().split())) ws = [] hs = [] for i in range(w): ws.append(int(input())) for i in range(h): hs.append(int(input())) ws.sort(reverse = True) hs.sort(reverse = True) remainW = w remainH = h aliveW = [1 for i in range(w)] aliveH = [1 for i in range(h)] ans = 0 while(remainW>0 or remainH>0): #print(ans, remainW, remainH) costW = ws[remainW-1] * (remainH + 1) costH = hs[remainH-1] * (remainW + 1) if(ws[remainW-1] > hs[remainH-1] or remainW==0): ans += costH remainH-=1 else: ans += costW remainW -= 1 print(ans)
s963890725
p03972
u366541443
1588622266
Python
PyPy3 (2.4.0)
py
Runtime Error
863
67928
575
w,h = list(map(int, input().split())) ws = [] hs = [] for i in range(w): ws.append(int(input())) for i in range(h): hs.append(int(input())) ws.sort(reverse = True) hs.sort(reverse = True) remainW = w remainH = h aliveW = [1 for i in range(w)] aliveH = [1 for i in range(h)] ans = 0 while(remainW>0 or remainH>0): #print(ans, remainW, remainH) costW = ws[remainW-1] * (remainH + 1) costH = hs[remainH-1] * (remainW + 1) if(costW > costH or remainW==0): ans += costH remainH-=1 else: ans += costW remainW -= 1 print(ans)
s341176113
p03972
u789436713
1586854813
Python
Python (3.4.3)
py
Runtime Error
2208
1615272
1001
W,H=[int(item) for item in input().split()] p=[] for _ in range(W): p.append(int(input())) q=[] for _ in range(H): q.append(int(input())) cost = [[114514] * (W+1) for i in range(H+1)] cost[0][0]=0 cnt = 1 totalcost=0 while True: if cnt <= H : x,y=0,cnt else: x,y=cnt-H,H if cnt-H==W+1:break while y>=0 and x<=W: if x == 0: cost[x][y]=cost[x][y-1]+q[y-1] totalcost+=q[y-1] elif y == 0: cost[x][y]=cost[x-1][y]+p[x-1] totalcost+=p[x-1] else: totalcost += p[x - 1] if p[x - 1] < q[y - 1] else q[y-1] # if cost[x][y - 1] + q[y - 1] < cost[x - 1][y] + p[x - 1]: # cost[x][y]=cost[x][y-1]+q[y-1] # totalcost+=q[y-1] # else: # cost[x][y]=cost[x-1][y]+p[x-1] # totalcost += p[x - 1] #print(x,y) x += 1 y -= 1 #print(cnt) #print(cost) cnt += 1 print(totalcost)
s507638529
p03972
u638795007
1579061987
Python
Python (3.4.3)
py
Runtime Error
278
12168
1647
def examA(): S = SI(); N = len(S) T = "CODEFESTIVAL2016" ans = 0 for i in range(N): if S[i]!=T[i]: ans +=1 print(ans) return def examB(): N, A, B = LI() S = SI() d = defaultdict(int) for s in S: if s=="a": if d["a"]+d["b"]<A+B: print("Yes") d[s] += 1 else: print("No") elif s=="b": if d["a"]+d["b"]<A+B and d["b"]<B: print("Yes") d[s] += 1 else: print("No") else: print("No") return def examC(): W, H = LI() P = [I() for _ in range(W)]; P.sort() Q = [I() for _ in range(H)]; Q.sort() dh = 0; dw = 0 p = 0; q = 0 ans = 0 for i in range(H+W): if (p<W and P[p]<Q[q]) or q>=H: ans += P[p]*(H+1-dh) p +=1; dw +=1 else: ans += Q[q]*(W+1-dw) q +=1; dh+=1 print(ans) return import sys,copy,bisect,itertools,heapq,math from heapq import heappop,heappush,heapify from collections import Counter,defaultdict,deque def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) def LSI(): return list(map(str,sys.stdin.readline().split())) def LS(): return sys.stdin.readline().split() def SI(): return sys.stdin.readline().strip() global mod,mod2,inf,alphabet,ALPHABET, _ep mod = 10**9 + 7 mod2 = 998244353 inf = 10**18 _ep = 1e-9 alphabet = [chr(ord('a') + i) for i in range(26)] ALPHABET = [chr(ord('A') + i) for i in range(26)] if __name__ == '__main__': examC()
s237911577
p03972
u638795007
1579061930
Python
Python (3.4.3)
py
Runtime Error
286
12168
1645
def examA(): S = SI(); N = len(S) T = "CODEFESTIVAL2016" ans = 0 for i in range(N): if S[i]!=T[i]: ans +=1 print(ans) return def examB(): N, A, B = LI() S = SI() d = defaultdict(int) for s in S: if s=="a": if d["a"]+d["b"]<A+B: print("Yes") d[s] += 1 else: print("No") elif s=="b": if d["a"]+d["b"]<A+B and d["b"]<B: print("Yes") d[s] += 1 else: print("No") else: print("No") return def examC(): W, H = LI() P = [I() for _ in range(W)]; P.sort() Q = [I() for _ in range(H)]; Q.sort() dh = 0; dw = 0 p = 0; q = 0 ans = 0 for i in range(H+W): if p<W and P[p]<Q[q] or q>=H: ans += P[p]*(H+1-dh) p +=1; dw +=1 else: ans += Q[q]*(W+1-dw) q +=1; dh+=1 print(ans) return import sys,copy,bisect,itertools,heapq,math from heapq import heappop,heappush,heapify from collections import Counter,defaultdict,deque def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) def LSI(): return list(map(str,sys.stdin.readline().split())) def LS(): return sys.stdin.readline().split() def SI(): return sys.stdin.readline().strip() global mod,mod2,inf,alphabet,ALPHABET, _ep mod = 10**9 + 7 mod2 = 998244353 inf = 10**18 _ep = 1e-9 alphabet = [chr(ord('a') + i) for i in range(26)] ALPHABET = [chr(ord('A') + i) for i in range(26)] if __name__ == '__main__': examC()
s102579064
p03972
u533885955
1568073861
Python
Python (3.4.3)
py
Runtime Error
617
42632
802
#C問題 #UnionFind def find(A,x): p = A[x] if p == x: return x a = find(A,p) A[x] = a return a def union(A, x, y): if find(A,x) > find(A,y): bx, by = find(A,y), find(A,x) else: bx, by = find(A,x), find(A,y) A[y] = bx A[by] = bx import heapq H,W = map(int,input().split()) PQ = [] for i in range(W+H+1): if i == W: continue pq = int(input()) heapq.heappush(PQ,[pq,i,i+1]) uf = UnionFind(H+W+2) a = W+1 b = H+1 ans = 0 V = [i for i in range(H+W+2)] while PQ: edge = heapq.heappop(PQ) w,s,t = edge[0],edge[1],edge[2] if find(V,s) != find(V,t): union(V,s,t) if s < W+1: #P ans+=w*b a-=1 else:#Q ans+=w*a b-=1 print(ans)
s493251206
p03972
u727801592
1567570243
Python
Python (3.4.3)
py
Runtime Error
2104
145184
524
import sys #入力時間短縮 input = sys.stdin.readline W,H=map(int,input().split()) p=sorted(int(input()) for i in range(W)) q=sorted(int(input()) for i in range(H)) ans=sum(p)*(H+1)+sum(q)*(W+1) #1マスずつmax(pi,qj)→O(N^2) #pi,qjが大きい順に列ごと消去→O(N) for i in range(W+H-1): if p[len(p)-1]>=q[len(q)-1]: ans-=p[len(p)-1]*len(q) p.pop() if p==[]: print(ans) exit() else: ans-=q[len(q)-1]*len(p) q.pop() if q==[]: print(ans) exit() print(p,q)
s696527098
p03972
u727801592
1567569320
Python
Python (3.4.3)
py
Runtime Error
327
13360
332
import sys input = sys.stdin.readline W,H=map(int,input().split()) p=sorted(int(input()) for i in range(W)) q=sorted(int(input()) for i in range(H)) ans=sum(p)*(H+1)+sum(q)*(W+1) for i in range(W+H-1): if p[len(p)-1]>=q[len(q)-1]: ans-=p[len(p)-1]*len(q) p.pop() else: ans-=q[len(q)-1]*len(p) q.pop() print(ans)
s607584636
p03972
u023540496
1555950587
Python
PyPy3 (2.4.0)
py
Runtime Error
884
61272
652
W,H = (int(num) for num in input().split()) p = [int(input()) for _ in range(W)] p.sort() q = [int(input()) for _ in range(H)] q.sort() p_cnt = H+1 #何本取るか q_cnt = W+1 gr_cnt = (W+1) * (H+1) - 1 p_idx = 0 q_idx = 0 ans = 0 while gr_cnt > 0: if (p_idx < W and p[p_idx] <= q[q_idx]) or q_idx >= H: nt = min(p_cnt,gr_cnt) #print(gr_cnt,nt,p[p_idx]) ans += p[p_idx] * nt gr_cnt -= nt q_cnt -= 1 p_idx += 1 else: nt = min(q_cnt,gr_cnt) #print(gr_cnt,nt,q[q_idx]) ans += q[q_idx] * nt gr_cnt -= nt p_cnt -= 1 q_idx += 1 print(ans)
s587965510
p03972
u563710899
1477949010
Python
Python (2.7.6)
py
Runtime Error
1583
12404
466
W,H=map(int,raw_input().split()) p=[input() for i in range(W)] q=[input() for i in range(H)] p.sort(reverse=True) q.sort(reverse=True) cost=0 del_H=0 del_W=0 len_p=W len_q=H while len_p>0 and len_q>0: if p[del_W]>q[del_H]: del_W+=1 cost+=p[del_W]*(del_H+1) len_p-=1 else: del_H+=1 cost+=q[del_H]*(del_W+1) len_q-=1 if len_p==0: cost+=sum(q)*(W+1) else: cost+=sum(p)*(H+1) print cost
s098248725
p03972
u501661505
1476142993
Python
Python (2.7.6)
py
Runtime Error
19
2816
867
from heapq import heappop, heappush from networkx import nx import sys def build_graph(W, H, p, q): graph = nx.Graph() for i in range(W): for j in range(H): x = j*W + i if i+1 < W: graph.add_edge(x, x+1, weight=p[i]) if j+1 < H: graph.add_edge(x, x+W, weight=q[j]) return graph def prim(G, s): P, Q = {}, [(0, None, s)] while Q: _, p, u = heappop(Q) if u in P: continue P[u] = p for v, w in G[u].items(): heappush(Q, (w, u, v)) return sum(G[key][P[key]]['weight'] for key in P if P[key] != None) W, H = map(int, raw_input().split(' ')) p = [0] * W q = [0] * H for i in xrange(W): p[i] = int(raw_input()) for j in xrange(H): q[j] = int(raw_input()) W+=1 H+=1 g = build_graph(W, H, p, q) p = prim(g, 0) print p
s920260972
p03972
u104282757
1476135577
Python
PyPy2 (5.6.0)
py
Runtime Error
204
27036
664
W, H = map(int, raw_input().split()) p_list = list() q_list = list() for i in range(W): p_list.append(int(raw_input())) for j in range(H): q_list.append(int(raw_input())) p_list.sort() q_list.sort() cp = H+1 cq = W+1 res = 0 pid = 0 qid = 0 while True: if pid == H: if qid == W: break else: choice = 'q' elif qid == W: choice = 'p' elif p_list[pid] < q_list[qid]: choice = 'p' else: choice = 'q' if choice == 'p': cq -= 1 res += cp*p_list[pid] pid += 1 else: cp -= 1 res += cq*q_list[qid] qid += 1 print res
s005539598
p03972
u079701009
1476126380
Python
Python (2.7.6)
py
Runtime Error
548
9660
432
w, h = map(int, raw_input().split()) p = [] q = [] for i in xrange(w): p.append(int(raw_input())) for i in xrange(h): q.append(int(raw_input())) wl = w hl = h cost = 0 p.sort() q.sort() p.append(10 ** 8) q.append(10 ** 8) pc = 0 qc = 0 while(wl + hl - pc - qc> 0): if p[pc] < q[qc]: cost += (hl - qc + 1) * p[pc] pc += 1 else: cost += (wl - pc + 1) * q[qc] qc += 1 print cost
s801256145
p03972
u079701009
1476126256
Python
Python (2.7.6)
py
Runtime Error
472
14544
454
w, h = map(int, raw_input().split()) p = [] q = [] for i in xrange(w): p.append(raw_input()) p = map(int, p) for i in xrange(h): q.append(raw_input()) q = map(int, q) wl = w hl = h cost = 0 p.sort() q.sort() p.append(10 ** 8) q.append(10 ** 8) pc = 0 qc = 0 while(wl + hl - pc - qc> 0): if p[pc] < q[qc]: cost += (hl - qc + 1) * p[pc] pc += 1 else: cost += (wl - pc + 1) * q[qc] qc += 1 print cost
s202828895
p03972
u079701009
1476126181
Python
Python (2.7.6)
py
Runtime Error
367
14424
526
# import time w, h = map(int, raw_input().split()) p = [] q = [] for i in xrange(w): p.append(raw_input()) p = map(int, p) for i in xrange(h): q.append(raw_input()) q = map(int, q) start = time.time() wl = w hl = h cost = 0 p.sort() q.sort() p.append(10 ** 8) q.append(10 ** 8) pc = 0 qc = 0 while(wl + hl - pc - qc> 0): if p[pc] < q[qc]: cost += (hl - qc + 1) * p[pc] pc += 1 else: cost += (wl - pc + 1) * q[qc] qc += 1 print cost # print time.time() - start
s161558378
p03972
u501661505
1476125926
Python
Python (2.7.6)
py
Runtime Error
17
2696
1134
import sys _=sys.maxint def build_graph(W, H, p, q): vetex = W * H graph = [[_] * vetex ] * vetex for i in range(W): for j in range(H): x = i*W + j if i+1 < W: graph[x][x+W] = p[i] if j+1 < H: graph[x][x+1] = q[j] return graph W, H = map(int, raw_input().split(' ')) p = [0] * W q = [0] * H for i in xrange(W): p[i] = int(raw_input()) for j in xrange(H): q[j] = int(raw_input()) W+=1 H+=1 n = W*H g = build_graph(W,H,p,q) def prim(graph,n): dis=[0]*n pre=[0]*n flag=[False]*n flag[0]=True k=0 for i in range(n): dis[i]=graph[k][i] for j in range(n-1): mini=_ for i in range(n): if mini>dis[i] and not flag[i]: mini=dis[i] k=i if k==0:#不连通 return flag[k]=True for i in range(n): if dis[i]>graph[k][i] and not flag[i]: dis[i]=graph[k][i] pre[i]=k return dis,pre dis, pre = prim(g, n) print sum(dis[1:])
s599839389
p03972
u501661505
1476125795
Python
Python (2.7.6)
py
Runtime Error
16
2696
1125
_=float('inf') def build_graph(W, H, p, q): vetex = W * H graph = [[_] * vetex ] * vetex for i in range(W): for j in range(H): x = i*W + j if i+1 < W: graph[x][x+W] = p[i] if j+1 < H: graph[x][x+1] = q[j] return graph W, H = map(int, raw_input().split(' ')) p = [0] * W q = [0] * H for i in xrange(W): p[i] = int(raw_input()) for j in xrange(H): q[j] = int(raw_input()) W+=1 H+=1 n = W*H g = build_graph(W,H,p,q) def prim(graph,n): dis=[0]*n pre=[0]*n flag=[False]*n flag[0]=True k=0 for i in range(n): dis[i]=graph[k][i] for j in range(n-1): mini=_ for i in range(n): if mini>dis[i] and not flag[i]: mini=dis[i] k=i if k==0:#不连通 return flag[k]=True for i in range(n): if dis[i]>graph[k][i] and not flag[i]: dis[i]=graph[k][i] pre[i]=k return dis,pre dis, pre = prim(g, n) print sum(dis[1:])
s851634423
p03972
u744592787
1476124927
Python
Python (3.4.3)
py
Runtime Error
23
3064
515
def cost(x, y, a): if x[0] == y[0] and abs(x[1]-y[1])==1: if x[1] > y[1]: return a[1][y[i]] else: return a[1][x[i]] elif x[1] == y[1] and abs(x[0]-y[0])==1: if x[0] > y[0]: return a[0][y[i]] else: return a[0][x[i]] W = 2 H = 2 a = [[0 for i in range(W)] for j in range(H)] for i in range(W): for j in range(H): a[i][j] = 1#input() a = [[3,5], [2,7]] z = list(itertools.product([0, 1, 2], repeat=2)) print(29)
s279348884
p03972
u725662235
1476124903
Python
Python (2.7.6)
py
Runtime Error
1668
15532
615
w,h= map(int, raw_input().split()) p =[] q = [] for i in xrange(w): t = input() p.append(t) for i in xrange(h): t = input() q.append(t) p =sorted(p,reverse=True) q =sorted(q, reverse=True) ac = p[:] acq = q[:] i = w-2 while i >=0: ac[i] += ac[i+1] i -=1 i = h - 2 while i >= 0: acq[i] += acq[i + 1] i -= 1 c = ac[0] + acq[0] k = 0 # for i in xrange(h): i = 0 while i < h: # for j in xrange(k,w): j = k if q[i] > p[j]: c += ac[j] i += 1 # break else: c +=acq[i] k +=1 # c += q[i] print c
s416862672
p03972
u830390742
1476122517
Python
PyPy2 (5.6.0)
py
Runtime Error
420
46492
1241
W, H = map(int, raw_input().split()) p = sorted([(i, int(raw_input())) for i in xrange(W)], key=lambda x:-x[1]) q = sorted([(i, int(raw_input())) for i in xrange(H)], key=lambda x:-x[1]) class UnionFind(object): def __init__(self, n): self.uf = [-1 for _ in xrange(n)] def union(self, x, y): x = self.find(x[0] + x[1]*(W+1)) y = self.find(y[0] + y[1]*(W+1)) if x == y: return False if self.uf[x] >= self.uf[y]: self.uf[y] += self.uf[x] self.uf[x] = y else: self.uf[x] += self.uf[y] self.uf[y] = x return True def find(self, x): leaves = [] while self.uf[x] >= 0: leaves.append(x) x = self.uf[x] for lf in leaves: self.uf[lf] = x return x uf = UnionFind((W+1)*(H+1)) ans = 0 while len(p) > 0 or len(q) > 0: if len(q) == 0 or (len(p) > 0 and p[-1][1] <= q[-1][1]): i, cost = p.pop() for j in xrange(H+1): if uf.union((i, j), (i+1, j)): ans += cost else: j, cost = q.pop() for i in xrange(W+1): if uf.union((i, j), (i, j+1)): ans += cost print ans
s970984938
p03972
u406648710
1476122024
Python
Python (2.7.6)
py
Runtime Error
16
2568
1310
neighbor = lambda c, w, h: filter( lambda b: 0 <= b[0] <= w and 0 <= b[1] <= h, [ (c[0]-1, c[1]), (c[0]+1, c[1]), (c[0], c[1]-1), (c[0], c[1]+1) ] ) def q_c(): t = raw_input() W, H = map(int, t.split(' ')) p, q = [], [] for i in xrange(W): p.append(int(raw_input())) for j in xrange(H): q.append(int(raw_input())) has = [[False for i in xrange(H+1)] for j in xrange(W+1)] has[0][0] = True Next = [(1, 0), (0, 1)] cost = 0 for i in xrange(W*H+W+H): Min = 100000005 choose = None Next.sort(key=lambda a: min(p[a[0]-1] if a[0] > 0 else 100000005, q[a[1]-1] if a[1] > 0 else 100000005)) choose = Next[-1] Min = min(p[choose[0]-1] if choose[0] > 0 else 100000005, q[choose[1]-1] if choose[1] > 0 else 100000005) # for each in Next: # if each[0] > 0: # if p[each[0]-1] < Min: # choose = each # Min = p[each[0]-1] # if each[1] > 0: # if q[each[1]-1] < Min: # choose = each # Min = q[each[1]-1] has[choose[0]][choose[1]] = True Next = Next[:-1] cost += Min for every in neighbor(choose, W, H): # print every if not has[every[0]][every[1]] and every not in Next: Next.append(every) print cost
s559266282
p03973
u600402037
1582741180
Python
Python (3.4.3)
py
Runtime Error
17
2940
332
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() A = [ir() for _ in range(N)] answer = A[0] - 1 cur_limit = 2 for a in A[1:]: if a == cur_limit: cur_limit += 1 continue answer += (a-cur_limit) // cur_limit) print(answer) # 44
s593234629
p03973
u905582793
1581704882
Python
PyPy3 (2.4.0)
py
Runtime Error
169
38512
234
import sys input = sys.stdin.readline n = int(input()) a = [int(input()) for i in range(n)] cnt = 1 ans = 0 for i in range(n): if a[i] = cnt+1: cnt += 1 else: ans += (a[i]-1)//cnt if cnt == 1: cnt += 1 print(ans)
s439594688
p03973
u731028462
1476155022
Python
Python (3.4.3)
py
Runtime Error
23
3064
235
#!/usr/bin/env python3 # -*- coding: utf-8 -*- n = int(input()) arr = [int(input()) for _ in range(N)] count = arr[0]-1 m = 1 for a in arr[1:]: if a == m: m += 1 if a > m: count += (a - 1) // (m+1) print(count)
s033652688
p03973
u664481257
1476125517
Python
Python (3.4.3)
py
Runtime Error
629
8932
1069
# -*- coding: utf-8 -*- # !/usr/bin/env python # vim: set fileencoding=utf-8 : """ # # Author: Noname # URL: https://github.com/pettan0818 # License: MIT License # Created: 2016-10-10 # # Usage # """ def read_value(): num_customer = input() return [int(input()) for _ in range(num_customer)] def greed_canceler(customers): """ >>> greed_canceler([3,2,5]) 3 >>> greed_canceler([3,1,4,1,5,9,2,6,5,3,5,8,9,7,9]) 18 """ selled = 0 must_above = 1 for i, n in enumerate(customers): flag = False while must_above < customers[i]: flag = True selled += 1 #print("Processing col: {0} of {1}".format(i, customers[i])) customers[i] = customers[i] - must_above #print("must_above: {0}".format(must_above)) #print(customers[i]) if not must_above < customers[i]: must_above = customers[i] + 1 return selled if __name__ == "__main__": import doctest doctest.testmod() greed_canceler(read_value())
s377069418
p03973
u657357805
1476125014
Python
Python (3.4.3)
py
Runtime Error
23
3192
267
N=int(input()) a=[0]*N for i in range(N): a.[i]=int(input()) minimum=1 count=0 for i in a: if(minimum<i): if i%minimum: count+= i//minimum else : count+= (i//minimum-1) else: minimum=max(minimum,i+1) print(count)
s372043397
p03973
u098968285
1476124509
Python
Python (3.4.3)
py
Runtime Error
24
3192
393
# def makelist(n, m): # return [[0 for i in range(m)] for j in range(n)] n = int(input()) A = [0]*N for i in range(N): A[i] = int(input()) ans = A[0] - 1 A[0] = 1 cnt = 1 # yobi = 1 for i in range(1, N): now = A[i] if now > cnt: if now == cnt + 1: ## 0 ni nattyau cnt += 1 else: ## now >= cnt + 2 ans += now // (cnt + 1) if now % (cnt + 1) == 0: ans -= 1 print(ans)
s448854847
p03974
u557523358
1476254415
Python
PyPy3 (2.4.0)
py
Runtime Error
476
302960
531
import array;R=range;L=input;T=[0]*28;N=int(L());S=[];U=N*26**2*array.array('i',[0]);V=N*[0];Q=int(L()) for I in R(N): S+=[[ord(C)-95 for C in L()]];P=0 for C in S[I]: if T[P+C]==0:T[P+C]=len(T);T+=[0]*28 T[P]+=1;P=T[P+C] T[P]+=1;T[P+1]=1 while N: N-=1;P=0 for C in S[N]: for A in R(26): X=T[P+A+2] if(A!=C-2)*X:U[676*N+26*A+C-2]+=T[X] V[N]+=T[P+1] P=T[P+C] while Q: K,P=L().split();K=int(K)-1;P=[ord(C)-97 for C in P];X=1+V[K] for A in R(26): for B in R(A+1,26): X+=U[676*K+26*P[A]+P[B]] print(X);Q-=1
s149630813
p03975
u223904637
1574617517
Python
PyPy3 (2.4.0)
py
Runtime Error
169
38384
190
import bisect n,a,b=map(int,input().split()) t=set([]) for i in range(n): t.add(int(input())) t=list(t) t.sort() ai=bisect.bisect_left(t,a) bi=bisect.bisect_left(t,b) print(ans-(bi-ai))
s095788524
p03975
u596421790
1574185348
Python
Python (3.4.3)
py
Runtime Error
18
3060
108
n,a,b = map(int, input().split()) l = [int(input()) for _ in range(n)] print(len(filter(lambda x:a<=x<b,l)))
s847754459
p03975
u516242950
1563932314
Python
Python (3.4.3)
py
Runtime Error
17
2940
156
n, a, b = map(int, input().split()) 2.kazu = 0 3.for cl in range(n): 4. jugyo = int(input()) 5. if a > jugyo or jugyo >= b: 6. kazu += 1 7.print(kazu)