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
s316894676
p03785
u744920373
1584842392
Python
Python (3.4.3)
py
Runtime Error
17
3064
250
N = int(input()) A = sorted(list(map(int, input().split()))) tmp = 0 sum_a = sum(A) ind = N+1 for i in range(N-1): #tmp += A[i]*2 tmp = 2*sum(A[:i+1]) if tmp < A[i+1]: ind = i if ind == N+1: print(N) else: print(N-ind-1)
s884768539
p03785
u539517139
1583774181
Python
Python (3.4.3)
py
Runtime Error
2104
7812
259
n,c,k=map(int,input().split()) t=[int(input()) for _ in range(n)]+[10**9] t.sort() b=1 p=0 while p<n: l=t[p]+k pp=1 f=1 while pp<c and f: p+=1 if t[p]<=l: pp+=1 if pp==c: p+=1 else: f=0 if p<n: b+=1 print(b)
s010338295
p03785
u004423772
1583624344
Python
Python (3.4.3)
py
Runtime Error
17
3060
329
T = [int(input()) for _ in range(N)] T.sort() def init_bus(): global bus, min_t, ans bus = [] bus.append(t) min_t = t ans += 1 min_t = 0 for t in T: if len(bus) == 0: init_bus() continue if t - min_t < K and len(bus) < C: bus.append(t) else: init_bus() print(ans)
s097580406
p03785
u747703115
1583160209
Python
Python (3.4.3)
py
Runtime Error
17
3064
328
n, c, k = map(int, input().split()) T = [0]*n for i in range(n): T[i] = int(input()) T.sort() ans = 0 jk = 0 t = T[0] for i in range(n): if T[i]-t>k: ans += 1 jk = 0 t = T[i] continue jk += 1 if jk==c: ans += 1 jk = 0 t = T[i] print(ans if jk== else ans+1)
s715840116
p03785
u757030836
1582469371
Python
Python (3.4.3)
py
Runtime Error
185
7104
258
n,c,k = map(int,input().split()) t = [int(input()) for i in range(n)] t.sorted() pas = 1 last_bus = t[0] + k ans = 1 for i in t[1:]: if i <= last_bus and pas < c: pas +=1 else: ans +=1 pas =1 last_bus = i + k print(ans)
s026427808
p03785
u867848444
1580696377
Python
Python (3.4.3)
py
Runtime Error
289
8256
573
n,c,k=map(int,input().split()) t=[int(input()) for i in range(n)] t=sorted(t) ans=0 cnt=0 first_time=t[0] for i in range(n): time=t[i]-first_time cnt+=1 if time==0: if i<=n-2 and t[i+1]-first_time>k: ans+=1 first_time=t[i+1] cnt=0 elif cnt==c: ans+=1 first_time=t[i+1] cnt=0 elif time>k: ans+=1 first_time=t[i] cnt=0 elif cnt==c: ans+=1 first_time=t[i+1] cnt=0 if i==n-1 and cnt!=0: ans+=1 print(ans)
s079523058
p03785
u431981421
1578856167
Python
Python (3.4.3)
py
Runtime Error
17
2940
319
N,C,K = map(int,input().split()) li = [] for t in range(N): li.append(int(input())) count = 0 ans = 0 newLi = sorted(li) while(len(newLi)): for c in range(C - 1): if len(newLi) < 2: break if newLi[1] <= newLi[0] + K: newLi.pop(1) else: break newLi.pop(0) ans += 1 print(ans)
s092329737
p03785
u062189367
1578780142
Python
Python (3.4.3)
py
Runtime Error
2144
669648
516
import sys N, C, K = list(map(int, input().split())) listT = [int(input()) for _ in range(N)] listT.sort() def func(listT,bus): if len(listT)<2: print(bus+1) sys.exit() elif len(listT)>=2: for i in range(1,max(C,len(listT))): if listT[i]-listT[0]>K: bus += 1 return func(listT[i:],bus) bus += 1 if len(listT)<C: print(bus) sys.exit() return func(listT[C:],bus) func(listT,0)
s415293443
p03785
u105302073
1577804306
Python
Python (3.4.3)
py
Runtime Error
335
16876
263
N, C, K = [int(i) for i in input().split()] T = sorted([int(input())] for i in range(N)) ans = 1 limit = 0 ti = T[0] for i in range(N - 1): limit += 1 if ti + K < T[i + 1] or limit == C: ti = T[i + 1] ans += 1 limit = 0 print(ans)
s430716279
p03785
u105302073
1577804236
Python
Python (3.4.3)
py
Runtime Error
17
3060
270
N, C, K = [int(i) for i in input().split()] T = list(sorted([int(i) for i in input().split()])) ans = 1 limit = 0 ti = T[0] for i in range(N - 1): limit += 1 if ti + K < T[i + 1] or limit == C: ti = T[i + 1] ans += 1 limit = 0 print(ans)
s345064087
p03785
u105302073
1577804209
Python
Python (3.4.3)
py
Runtime Error
17
3060
270
N, C, K = [int(i) for i in input().split()] T = list(sorted([int(i) for i in input().split()])) ans = 1 limit = 0 ti = T[0] for i in range(N - 1): limit += 1 if ti + K < T[i + 1] or limit == C: ti = T[i + 1] ans += 1 limit = 0 print(ans)
s594759127
p03785
u934052933
1576509963
Python
Python (3.4.3)
py
Runtime Error
210
8280
665
def main()->None: N, C, K = map(int, input().split()) range_N = range(N) T = [int(input()) for i in range_N] # バスの出発時刻 T = sorted(T) bus = 0 passenger = 0 start = 0 for i in range_N: if passenger == 0: start = t[i] + K passenger = 1 elif passenger == C: bus += 1 start = t[i] + K passenger = 1 else: if t[i] > start: bus += 1 start = t[i] + K passenger = 1 else: passenger += 1 print(bus+1) if __name__ == "__main__": main()
s158548529
p03785
u934052933
1576509822
Python
Python (3.4.3)
py
Runtime Error
33
7856
659
def main()->None: N, C, K = map(int, input().split()) range_N = range(N) T = [int(i) for i in range_N] # バスの出発時刻 T = sorted(T) bus = 0 passenger = 0 start = 0 for i in range_N: if passenger == 0: start = t[i] + K passenger = 1 elif passenger == C: bus += 1 start = t[i] + K passenger = 1 else: if t[i] > start: bus += 1 start = t[i] + K passenger = 1 else: passenger += 1 print(bus+1) if __name__ == "__main__": main()
s252778585
p03785
u832152513
1574800951
Python
PyPy3 (2.4.0)
py
Runtime Error
631
54872
282
import bisect n, c, k = map(int, input().split()) t = sorted([int(input()) for _ in range(n)]) def AirportBus(x=0, y=0): if x == n: return y = min(bisect.bisect(t, t[x]+k), x+3) l.append(t[x:y]) AirportBus(y) l = [] AirportBus() print(len(l))
s070116720
p03785
u832152513
1574800124
Python
PyPy3 (2.4.0)
py
Runtime Error
634
55128
351
n, c, k = map(int, input().split()) t = sorted([int(input()) for _ in range(n)]) def AirportBus(x=0): y = x for i in range(x, n): if t[x]+k < t[i] or i-x >= c: y = i break if y == x: l.append(t[x:n]) return l.append(t[x:y]) AirportBus(y) l = [] AirportBus() print(len(l))
s309916323
p03785
u832152513
1574800027
Python
PyPy3 (2.4.0)
py
Runtime Error
630
55384
742
n, c, k = map(int, input().split()) t = sorted([int(input()) for _ in range(n)]) def AirportBus1(x=0): y = x for i in range(x, n): if t[x]+k < t[i] or i-x >= c: y = i break if y == x: l.append(t[x:n]) return l.append(t[x:y]) AirportBus1(y) def AirportBus2(x=0): y = x for i in range(x, n): if t[x]-k > t[i] or i-x >= c: y = i break if y == x: r.append(t[x:n]) return r.append(t[x:y]) AirportBus2(y) l = [] AirportBus1() t.sort(reverse = True) r = [] AirportBus2() ans1 = 0 for lis in l: ans1 += -(-len(lis) // c) ans2 = 0 for lis in r: ans2 += -(-len(lis) // c) print(min(ans1,ans2))
s541789399
p03785
u832152513
1574797542
Python
PyPy3 (2.4.0)
py
Runtime Error
622
55128
399
n, c, k = map(int, input().split()) t = sorted([int(input()) for _ in range(n)], reverse = True) l = [] def AirportBus(x=0): y = x for i in range(x, n): if t[x]-k > t[i]: y = i break if y == x: l.append(t[x:n]) return l.append(t[x:y]) AirportBus(y) AirportBus() ans = 0 for lis in l: ans += -(-len(lis) // c) print(ans)
s602737287
p03785
u832152513
1574797256
Python
PyPy3 (2.4.0)
py
Runtime Error
646
55128
383
n, c, k = map(int, input().split()) t = sorted([int(input()) for _ in range(n)]) l = [] def AirportBus(x=0): y = x for i in range(x, n): if t[x]+k < t[i]: y = i break if y == x: l.append(t[x:n]) return l.append(t[x:y]) AirportBus(y) AirportBus() ans = 0 for lis in l: ans += -(-len(lis) // c) print(ans)
s008951019
p03785
u623687794
1573672607
Python
PyPy3 (2.4.0)
py
Runtime Error
2106
50520
380
n,c,k=map(int,input().split()) ans=1 l=[] for i in range(n): l.append(int(input())) l.sort() ride=[] while l: a=l.pop(0) rode=a ride.append(a) while len(ride)<c: if l==[]: break b=l[0] if b>ride[0]+k: ride.clear() ans+=1 break l.pop(0) ride.append(b) if len(ride)==c: ans+=1 ride.clear() break print(ans)
s620092579
p03785
u896741788
1573340439
Python
Python (3.4.3)
py
Runtime Error
303
19732
470
from collections import Counter as co hit,te,ji=map(int,input().split()) l=list(co(sorted([int(input()) for u in range(hit)])).items()) inc=0 ans=0 ef=len(l) for ix in range(hit): k,v=l[inc] ans-=(-v//te) nokori=te-v%te if v%te else 0 inc+=1 if inc==ef:break while nokori: if l[inc][0]>k+ji: break if l[inc][1]<=nokori: nokori-=l[inc][1] inc+=1 if inc==ef:break else:l[inc][1]-=nokori;break print(ans+1 if nokori else ans)
s307470646
p03785
u896741788
1573340079
Python
Python (3.4.3)
py
Runtime Error
315
19728
463
from collections import Counter as co hit,te,ji=map(int,input().split()) l=list(co(sorted([int(input()) for u in range(hit)])).items()) inc=0 ans=0 ef=len(l) for ix in range(hit): k,v=l[inc] ans-=(-v//te) nokori=te-v%te if v%te else 0 inc+=1 while nokori: if l[inc][0]>k+ji:break if l[inc][1]<=nokori: nokori-=l[inc][1] inc+=1 if inc==ef:break else:l[inc][1]-=nokori;break if inc==ef:break print(ans+1 if nokori else ans)
s253907669
p03785
u896741788
1573339961
Python
Python (3.4.3)
py
Runtime Error
17
3064
526
from collections import Counter as co hit,te,ji=map(int,input().split()) l=list(co(sorted([int(input()) for u in range(hit)])).items()) inc=0 ans=0 ef=len(l) if ef==1:print(-(-l[0][1]//te));break for ix in range(hit): k,v=l[0] ans-=(-v//te) nokori=te-v%te if v%te else 0 inc+=1 while nokori: if l[inc][0]>k+ji:break if l[inc][1]<=nokori: nokori-=l[inc][1] inc+=1 if inc==ef: break else: l[inc][1]-=nokori break if inc==ef: break print(ans+1 if nokori else ans)
s642374181
p03785
u896741788
1573339787
Python
Python (3.4.3)
py
Runtime Error
313
19732
461
from collections import Counter as co hit,te,ji=map(int,input().split()) l=list(co(sorted([int(input()) for u in range(hit)])).items()) inc=0 ans=0 ef=len(l) for ix in range(hit): k,v=l[0] ans-=(-v//te) nokori=te-v%te if v%te else 0 inc+=1 while nokori: if l[inc][0]>k+ji:break if l[inc][1]<=nokori: nokori-=l[inc][1] inc+=1 if inc==ef:break else:l[inc][1]-=nokori;break if inc==ef:break print(ans+1 if nokori else ans)
s370415331
p03785
u514401521
1571796180
Python
Python (3.4.3)
py
Runtime Error
289
7392
469
N, C, K = map(int, input().split()) T = [] for i in range(N): T.append(int(input())) T.sort() i = 0 start = 0 ans = 0 limit = C for i in range(N): if T[start] + K >= T[i + 1] and limit > 1 : limit -= 1 elif T[start] + K < T[i + 1] and limit > 1: ans += 1 limit = C start = i + 1 elif T[start] + K >= T[i + 1] and limit == 1: ans += 1 limit = C start = i + 1 if start != N: ans += 1 print(ans)
s518490427
p03785
u174273188
1571439249
Python
Python (3.4.3)
py
Runtime Error
238
7396
544
def resolve(): n, c, k = map(int, input().split()) t = list(int(input()) for _ in range(n)) t.sort() ans = 0 limit = t[0] + k bus = 0 for i in range(n): if t[i] <= limit: bus += 1 if bus == c: ans += 1 bus = 0 if i < n: limit = t[i + 1] + k else: ans += 1 bus = 1 limit = t[i] + k if bus > 0: ans += 1 print(ans) if __name__ == "__main__": resolve()
s130890286
p03785
u174273188
1571439212
Python
Python (3.4.3)
py
Runtime Error
233
7524
514
def resolve(): n, c, k = map(int, input().split()) t = list(int(input()) for _ in range(n)) t.sort() ans = 0 limit = t[0] + k bus = 0 for i in range(n): if t[i] <= limit: bus += 1 if bus == c: ans += 1 bus = 0 limit = t[i + 1] + k else: ans += 1 bus = 1 limit = t[i] + k if bus > 0: ans += 1 print(ans) if __name__ == "__main__": resolve()
s955089964
p03785
u174273188
1571439126
Python
Python (3.4.3)
py
Runtime Error
234
7496
510
def resolve(): n, c, k = map(int, input().split()) t = list(int(input()) for _ in range(n)) t.sort() ans = 0 limit = t[0] + k bus = 0 for i in range(n): if t[i] <= limit: bus += 1 if bus == c: ans += 1 bus = 0 limit = t[i + 1] + k else: ans += 1 bus = 1 limit = t[i] + k if bus: ans += 1 print(ans) if __name__ == "__main__": resolve()
s147540981
p03785
u993622994
1569184153
Python
Python (3.4.3)
py
Runtime Error
278
7380
491
N, C, K = map(int, input().split()) T = [int(input()) for _ in range(N)] T.sort() bus = 0 member = 1 time = T[0] + K for i in range(1, N): member += 1 if time < T[i]: bus += 1 member = 1 time = T[i] + K elif time > T[i] and member >= C: if C % member == 0: bus += C // member else: bus += C // member + 1 member = 0 time = T[i+1] + K else: pass if member > 0: bus += 1 print(bus)
s139943701
p03785
u927534107
1564062892
Python
PyPy3 (2.4.0)
py
Runtime Error
556
56536
266
from collections import deque n,c,k=map(int,input().split()) l=sorted([int(input()) for _ in range(n)],reverse=True) ans=0 d=deque(l) while len(d)!=0: ans+=1 t=d.popleft() cnt=1 while d[0]>=t-k and cnt<c: d.popleft() cnt+=1 print(ans)
s080576440
p03785
u388415336
1559892131
Python
Python (3.4.3)
py
Runtime Error
200
7444
607
passengers, bus_size, time_lim = map(int, input().split()) pass_list = [int(input()) for passenger in range(passengers)] pass_list.sort() front = 0 now = 0 cnt = 0 ans = 0 for psngr_lst in pass_list: if cnt == 0: front = i now = i cnt += 1 elif cnt == bus_size: front = i now = i cnt = 1 ans += 1 elif now - front <= time_lim: if i - front <= time_lim: now = i cnt += 1 else: front = i now = i cnt = 1 ans += 1 if cnt: ans += 1 print(ans)
s586338685
p03785
u532966492
1558812343
Python
Python (3.4.3)
py
Runtime Error
170
7072
276
N,C,K=map(int,input().split()) T=[int(input()) for _ in range(N)] flag=0 bus_cnt=0 First=T[i] bus_rider=1 bus_cnt=1 for i in range(N): if bus_rider<C and T[i]-First<=K: bus_rider+=1 else: First=T[i] bus_rider=1 bus_cnt+=1 print(bus_cnt)
s390548089
p03785
u070187104
1558733294
Python
Python (3.4.3)
py
Runtime Error
182
7068
625
if __name__ == '__main__': [N, C, K] = [int(i) for i in input().split()] T = [] for i in range(K): T.append(int(input())) T.sort() counter = 1 num_people = 0 flag = False for num in T: print(num) print(flag) num_people += 1 if flag: if num - first_time <= K and num_people <= C: continue else: counter += 1 num_people = 1 flag = False print('inc') else: first_time = num flag = True print(counter)
s954557339
p03785
u059436995
1556303844
Python
Python (3.4.3)
py
Runtime Error
245
8300
574
n, c, k = map(int, input().split()) T = sorted([int(input()) for _ in range(n)]) bus = 0 cus = 0 lmt = T[0] + k for t in T: if cus == 0 or t > lmt: bus += 1 cus += 1 lmt = t + k else: cus +=1 if cus == 3: cus = 0 print(bus) n, c, k = map(int, input().split()) T = sorted([int(input()) for _ in range(n)]) bus = 0 cus = 0 lmt = T[0] + k for t in T: if cus == 0 or t > lmt: bus += 1 cus += 1 lmt = t + k else: cus +=1 if cus == c: cus = 0 print(bus) 提出情報
s231335486
p03785
u950708010
1556218167
Python
Python (3.4.3)
py
Runtime Error
1742
8280
346
import bisect def solve(): n,c,k = (int(i) for i in input().split()) t = [int(input()) for i in range(n)] t = sorted(t,reverse = True) ans = 0 while t: ans += 1 customer = t.pop(0) if len(t) >= 1: for i in range(c-1): if customer <= t[0] + k: t.pop(0) else: break print(ans) solve()
s037051338
p03785
u950708010
1556217862
Python
PyPy3 (2.4.0)
py
Runtime Error
2114
53280
346
import bisect def solve(): n,c,k = (int(i) for i in input().split()) t = [int(input()) for i in range(n)] t = sorted(t,reverse = True) ans = 0 while t: ans += 1 customer = t.pop(0) if len(t) >= 1: for i in range(c-1): if customer <= t[0] + k: t.pop(0) else: break print(ans) solve()
s079601392
p03785
u950708010
1556217689
Python
Python (3.4.3)
py
Runtime Error
1752
7512
323
import bisect def solve(): n,c,k = (int(i) for i in input().split()) t = [int(input()) for i in range(n)] t.sort() ans = 0 while t: ans += 1 customer = t.pop(0) if len(t) >= 1: for i in range(c): if customer + k >= t[0]: t.pop(0) else: break print(ans) solve()
s477082254
p03785
u404710939
1556206723
Python
Python (3.4.3)
py
Runtime Error
247
8280
330
N, C, K = map(int, input().split(" ")) T = sorted([int(input()) for _ in range(N)]) bus = 1 key = T[0] pas = 0 for i in range(N): if T[i] - key > K: bus += 1 key = T[i] pas = 0 else: pas += 1 if pas == C: bus += 1 key = T[i+1] pas = 0 print(bus)
s705304685
p03785
u001687078
1554316569
Python
Python (3.4.3)
py
Runtime Error
222
7384
243
n, c, k = map(int, input().split()) t = [] for i in range(n): t.append(int(input())) t.sort() result = 1 j = 0 for i in range(n): if (t[j] - t[0]) > k or c == count: result += 1 t = t[j:] j = 1 else: j += 1 print(result)
s954110942
p03785
u292810930
1554264916
Python
Python (3.4.3)
py
Runtime Error
19
3188
325
N, C, K = map(int, input().split()) T = [int(input()) for i in range(N)] T.sort() answer = 0 while len(T) > 0: limit = T[0] + K counter = 0 while counter < C: if len(T) == 0: break if T[0] > limit: break del T[0] counter += 1 answer += 1 print(answer)
s006973017
p03785
u118642796
1553875141
Python
Python (3.4.3)
py
Runtime Error
210
7444
261
N,C,K = map(int,input().split()) T = [int(input()) for _ in range(N)].sort() time=T[0] count = 1 ans = 0 for i in range(1,N): if T[i]-time>K or count==C: time = T[i] count = 1 ans += 1 else: count += 1 if count>0: ans += 1 print(ans)
s712879710
p03785
u897329068
1552865911
Python
Python (3.4.3)
py
Runtime Error
245
8280
657
N,C,K = map(int,input().split()) Ts = sorted([int(input()) for _ in range(N)]) #print(Ts) ans = 0 firstFlag = True passenger = [] #firstTime lastNum for i in range(N): if firstFlag: passenger = [Ts[i],C-1] firstFlag = False #print("first",str(passenger),Ts[i],ans) elif i+1 != N -1: if passenger[0] + K <= Ts[i+1]: #print("time over",str(passenger),Ts[i],ans) ans += 1 firstFlag = True elif passenger[1] == 1: #print("full",str(passenger),Ts[i],ans) ans += 1 firstFlag = True else: #print("other",str(passenger),Ts[i],ans) passenger[1] -= 1 else: #print("close",str(passenger),ans) if not firstFlag: ans += 1 print(ans)
s213132907
p03785
u367130284
1551901700
Python
Python (3.4.3)
py
Runtime Error
1718
138856
363
a,b,c=map(int,input().split()) v=sorted([int(input())for i in range(a)]) print(v) bus=[] ans=0 for i in range(a-1): if v[i]+c<v[i+1]: ans+=1 bus=[] if i==a-2: ans+=1 else: bus.append(v[i]) print(bus) if len(bus)>=b: ans+=1 bus=[] if len(bus)>0: ans+=1 print(ans)
s641964961
p03785
u941753895
1551441268
Python
Python (3.4.3)
py
Runtime Error
272
7384
312
n,c,k=map(int,input().split()) if ' '.join(str(x) for x in [n,c,k])=='5 3 5': exit() l=[] for i in range(n): l.append(int(input())) l.sort() cnt=0 ind=0 while True: cnt+=1 if ind+1>=n: break a=l[ind] start=a+k for i in range(1,c): ind+=1 if l[ind]>start: break ind+=1 print(cnt)
s939013857
p03785
u102960641
1547745954
Python
Python (3.4.3)
py
Runtime Error
18
3060
175
n = int(input()) a = input() b = input() for i in range(n): if i == 1: if a == b: print(n) exit() if a[i:] == b[:-i]: print(n+i) exit() print(n*2)
s948621944
p03785
u213854484
1545854479
Python
Python (3.4.3)
py
Runtime Error
224
8280
271
N,C,K=map(int,input().split()) T=[] for i in range(N): p=int(input()) T.append(p) ans = 1 T = sorted(T) ind = 0 for i in range(T): if T[i] > T[ind]+K: ans += 1 ind = i elif i >= ind + C: ans += 1 ind = i print(ans)
s910330106
p03785
u213854484
1545854191
Python
Python (3.4.3)
py
Runtime Error
208
8276
253
N,C,K = map(int, input().split()) T = [int(input()) for i in range(N)] ans = 1 T = sorted(T) ind = 0 for i in range(T): if T[i] > T[ind]+K: ans += 1 ind = i elif i >= ind + C: ans += 1 ind = i print(ans)
s656929293
p03785
u213854484
1545853958
Python
Python (3.4.3)
py
Runtime Error
222
8280
265
N,C,K = map(int,input().split()) T = [] for i in range(N): T.append(int(input())) ans = 1 T = sorted(T) ind = 0 for i in range(T): if T[i] > T[ind]+K: ans += 1 ind = i elif i >= ind + C: ans += 1 ind = i print(ans)
s229734386
p03785
u213854484
1545853899
Python
Python (3.4.3)
py
Runtime Error
17
3064
265
N,C,K = map(int,input().split()) T = [] for i in range(N): L.append(int(input())) ans = 1 T = sorted(T) ind = 0 for i in range(T): if T[i] > T[ind]+K: ans += 1 ind = i elif i >= ind + C: ans += 1 ind = i print(ans)
s150283470
p03785
u397531548
1545192004
Python
Python (3.4.3)
py
Runtime Error
220
7392
269
N,C,K=map(int,input().split()) A=[] for i in range(N): a=int(input()) A.append(a) A.sort() k=K a=0 c=C j=1 while j<N: k-=A[j]-A[j-1] n-=1 if k>0 and c>0: j+=1 else: a+=1 c=C k=K j+=1 print(a+1)
s394766750
p03785
u397531548
1545191864
Python
Python (3.4.3)
py
Runtime Error
221
7488
269
N,C,K=map(int,input().split()) A=[] for i in range(N): a=int(input()) A.append(a) A.sort() k=K a=0 c=C j=1 while j<N: k-=A[j]-A[j-1] n-=1 if k>0 and c>0: j+=1 else: a+=1 c=C k=K j+=1 print(a+1)
s580909730
p03785
u323680411
1543089944
Python
Python (3.4.3)
py
Runtime Error
17
2940
515
import java.util.* fun main(args: Array<String>) { val sc = Scanner(System.`in`) val n = sc.nextInt() val c = sc.nextInt() val k = sc.nextInt() val t = Array(n) { sc.nextInt() } var ans = 0 var waitStart = 0 var waitPeople = 0 for (ti in t.sorted()) { if (ti - waitStart > k || waitPeople == c) { waitPeople = 0 } waitPeople++ if (waitPeople == 1) { waitStart = ti ans++ } } println(ans) }
s870305781
p03785
u724892495
1540481202
Python
Python (3.4.3)
py
Runtime Error
17
2940
563
import math N, C, K = map(int,input().split()) T = [int(input()) for i in range(N)] T.sort() last = T[0] ans = 0; awaiting = 1 for i in range(1,N): if T[i] <= last+K: awaiting += 1 if awaiting%C == 0: ans += awaiting // C awaiting = 0 last = T[i] # print("a") else: # print("b") else: if awaiting > 0: ans += 1 awaiting = 0 last = T[i] awaiting = 1 # print("c") if awaiting > 0: ans += 1 print(ans) # print(T)
s896580806
p03785
u671874447
1534399513
Python
Python (2.7.6)
py
Runtime Error
65
11860
3100
import sys def merge_delay_pattern(k, half1, half2): len1 = len(half1) len2 = len(half2) start, delay1_next = half1[0] start2 = half2[0][0] time1 = start - start2 mid_start = start + time1 + delay1_next offset2_num_period = (mid_start - start2) // k offset2_phase = mid_start - offset2_num_period * k for head2 in range(len2): if half2[head2][0] >= offset2_phase: head2 -= 1 break head2 += offset2_num_period * len2 head1 = 0 ret = [] prev = () half1.append((start + k, None)) pos1_next = start pos2_next, delay2_next = half2[head2 % len2] pos2_next += (head2 // len2) * k mid = pos2_next while True: if mid <= pos2_next: if head1 == len1: break head1 += 1 pos1, delay1 = pos1_next, delay1_next pos1_next, delay1_next = half1[head1] if pos2_next <= mid: head2 += 1 pos2, delay2 = pos2_next, delay2_next pos2_next, delay2_next = half2[head2 % len2] pos2_next += (head2 // len2) * k if delay1 == 0: mid = pos1_next + time1 if delay2 == 0: if prev is not None: ret.append((start, 0)) prev = None else: delay = pos2 + delay2 - time1 - start if prev != start + delay: ret.append((start, delay)) prev = start + delay if pos2_next <= mid: start = pos2_next - time1 else: start = pos1_next else: mid = pos1 + time1 + delay1 if mid <= pos2_next: if delay2 == 0: delay = delay1 else: delay = pos2 + delay2 - time1 - start if prev != start + delay: ret.append((start, delay)) prev = start + delay start = pos1_next return ret def get_delay_pattern(k, data, first, last): if last - first == 1: return data[first] middle = (first + last) // 2 half1 = get_delay_pattern(k, data, first, middle) half2 = get_delay_pattern(k, data, middle, last) return merge_delay_pattern(k, half1, half2) def solve(): data = [] int_list = [int(s) for s in sys.stdin.read().split()] n = int_list[0] k = int_list[1] position = 0 for i in range(2, (n + 1) * 2, 2): a = int_list[i] b = int_list[i + 1] if b == 1: a2 = a * 2 if k < a2: return -1 data.append([(-position, 0), (-position + k - a2, a2)]) position += a if not data: return position * 2 delay_pattern = get_delay_pattern(k, data, 0, len(data)) pat_adj_pairs = zip(delay_pattern, delay_pattern[1:] + [(delay_pattern[0][0] + k, None)]) delay_list = (pos + delay - next_pos for (pos, delay), (next_pos, _) in pat_adj_pairs if delay) return position * 2 + min(delay_list, default=0) print(solve())
s341681636
p03785
u671874447
1534399455
Python
Python (3.4.3)
py
Runtime Error
52
14052
3100
import sys def merge_delay_pattern(k, half1, half2): len1 = len(half1) len2 = len(half2) start, delay1_next = half1[0] start2 = half2[0][0] time1 = start - start2 mid_start = start + time1 + delay1_next offset2_num_period = (mid_start - start2) // k offset2_phase = mid_start - offset2_num_period * k for head2 in range(len2): if half2[head2][0] >= offset2_phase: head2 -= 1 break head2 += offset2_num_period * len2 head1 = 0 ret = [] prev = () half1.append((start + k, None)) pos1_next = start pos2_next, delay2_next = half2[head2 % len2] pos2_next += (head2 // len2) * k mid = pos2_next while True: if mid <= pos2_next: if head1 == len1: break head1 += 1 pos1, delay1 = pos1_next, delay1_next pos1_next, delay1_next = half1[head1] if pos2_next <= mid: head2 += 1 pos2, delay2 = pos2_next, delay2_next pos2_next, delay2_next = half2[head2 % len2] pos2_next += (head2 // len2) * k if delay1 == 0: mid = pos1_next + time1 if delay2 == 0: if prev is not None: ret.append((start, 0)) prev = None else: delay = pos2 + delay2 - time1 - start if prev != start + delay: ret.append((start, delay)) prev = start + delay if pos2_next <= mid: start = pos2_next - time1 else: start = pos1_next else: mid = pos1 + time1 + delay1 if mid <= pos2_next: if delay2 == 0: delay = delay1 else: delay = pos2 + delay2 - time1 - start if prev != start + delay: ret.append((start, delay)) prev = start + delay start = pos1_next return ret def get_delay_pattern(k, data, first, last): if last - first == 1: return data[first] middle = (first + last) // 2 half1 = get_delay_pattern(k, data, first, middle) half2 = get_delay_pattern(k, data, middle, last) return merge_delay_pattern(k, half1, half2) def solve(): data = [] int_list = [int(s) for s in sys.stdin.read().split()] n = int_list[0] k = int_list[1] position = 0 for i in range(2, (n + 1) * 2, 2): a = int_list[i] b = int_list[i + 1] if b == 1: a2 = a * 2 if k < a2: return -1 data.append([(-position, 0), (-position + k - a2, a2)]) position += a if not data: return position * 2 delay_pattern = get_delay_pattern(k, data, 0, len(data)) pat_adj_pairs = zip(delay_pattern, delay_pattern[1:] + [(delay_pattern[0][0] + k, None)]) delay_list = (pos + delay - next_pos for (pos, delay), (next_pos, _) in pat_adj_pairs if delay) return position * 2 + min(delay_list, default=0) print(solve())
s983657646
p03785
u952708174
1527793891
Python
Python (3.4.3)
py
Runtime Error
209
8280
677
def a_airport_bus(N, C, K, T): import bisect t = sorted(T) index = 0 # t[index]はまだバスに乗っていない人の内最も早い空港到着時刻 ans = 0 while index <= N - 1: # 時刻 t[index] にバスを出した場合乗り込める人数の候補 num_take_bus = bisect.bisect_right(t, t[index] + K) - index if num_take_bus > C: index += C # 定員分だけ乗せる else: index += tmp # 乗れるだけ乗せる ans += 1 # バスを1台出した return ans N, C, K = [int(i) for i in input().split()] T = [int(input()) for _ in range(N)] print(a_airport_bus(N, C, K, T))
s569435343
p03785
u846150137
1526089880
Python
Python (3.4.3)
py
Runtime Error
17
2940
291
n,c,k=[n,c,k=[int(i) for i in input().split()] a=sorted([int(input()) for i in range(n)]) b=[i+k for i in a] i0=[] ans=0 bi=0 for i in range(n): i0.append(a[i]) l=len(i0) if l== c or (b[bi] < a[i] and i!=0) : ans+=1 i0=[] bi=i if l != c and i==n-1: ans+=1 print(ans)
s991067162
p03785
u582577761
1502309250
Python
Python (2.7.6)
py
Runtime Error
12
2820
941
import sys class TailRecurseException: def __init__(self, args, kwargs): self.args = args self.kwargs = kwargs def tail_call_optimized(g): def func(*args, **kwargs): f = sys._getframe() if f.f_back and f.f_back.f_back and f.f_back.f_back.f_code == f.f_code: raise TailRecurseException(args, kwargs) else: while 1: try: return g(*args, **kwargs) except TailRecurseException, e: args = e.args kwargs = e.kwargs func.__doc__ = g.__doc__ return func n,m=map(int,raw_input().split()) vis,ci,cb,cc=[0]*(n+1),0,0,0 g=[[] for i in range(n+1)] def dfs(x,col): if vis[x]: return vis[x]==col vis[x],flag=col,True for i in g[x]: flag&=dfs(i,3-col) return flag for i in range(m): u,v=map(int,raw_input().split()) g[u]+=[v] g[v]+=[u] for i in range(1,n+1): if vis[i]==0: if len(g[i])==0: ci+=1 else: if dfs(i,1): cb+=1 else: cc+=1 print ci*ci+2*ci*(n-ci)+cc*cc+2*cb*cc+2*cb*cb
s495324157
p03785
u026450699
1491228724
Python
Python (2.7.6)
py
Runtime Error
10
2696
1159
FILE = open("coderData.txt", 'r') def raw_input(): return FILE.readline() N,C,K = map(int, raw_input().split(" ")) timelist = [] for i in range(0, N): timelist.append(int(raw_input())) timelist.sort() class Foo: timelist = [] buslist = [] firstId = 0 capacity = 0 def __init__(self, timelist): self.timelist = timelist def addBus(self, i): self.buslist.append(self.timelist[i]) self.firstId = i + 1 self.capacity = 0 def calc(self): for i in range(0, N): if i == N - 1: self.addBus(i) break nexttime = self.timelist[i + 1] self.capacity += 1 # timeover if nexttime > timelist[self.firstId] + K: self.addBus(i) continue # capacity over if self.capacity >= C: self.addBus(i) continue def printBusList(self): for bus in self.buslist: print(bus) def printTotalBusNum(self): print(len(self.buslist)) foo = Foo(timelist) foo.calc() foo.printTotalBusNum()
s355109237
p03785
u125205981
1489403075
Python
Python (3.4.3)
py
Runtime Error
17
3060
287
def main(): N = int(input()) A = list(map(int, input().split())) A.sort() i = 1 j = N - 1 x = sum(A) while j > 0: if (x - A[j]) * 2 >= A[j]: i += 1 else: break x -= A[j] j -= 1 print(str(i)) main()
s559735295
p03785
u125205981
1489383015
Python
PyPy3 (2.4.0)
py
Runtime Error
170
38640
271
def main(): N = int(input()) A = list(map(int, input().split())) A.sort() A.reverse() i = 1 j = 1 while j < N: if A[j - 1] / 2 <= sum(A[j:]): i += 1 else: break j += 1 print(str(i)) main()
s405871737
p03785
u177756077
1489376183
Python
Python (2.7.6)
py
Runtime Error
11
2568
273
#!/usr/bin/env python from sys import stdin N,C,K=map(int,raw_input(),split(" ")) T=map(int,stdin.read().split()) T.sort() t_star=t[0] b_star=0 cnt=0 for b,t in enumerate(T): if t-t_star>K or b-b_star+1==C: cnt+=1 t_star=t b_star=b print cnt
s858046342
p03785
u613266984
1489371793
Python
Python (3.4.3)
py
Runtime Error
1968
402852
182
N,C,K = (int(i) for i in input().split()) Ti = [int(input()) for i in range(N)] for i in Ti: array=[] for j in range(K+1): array.append(i+j) Ti_box.append(array)
s434625009
p03785
u369752439
1489371143
Python
Python (2.7.6)
py
Runtime Error
10
2568
703
def count_bus(N, C, K, tList): B = 0 while(len(tList) > 0): firstTime = tList[0] leaveTime = tList[0] + int(K) count = 0 for i in range(int(C)): if(i >= len(tList)): break if(tList[i] < leaveTime): count = count + 1 tList = tList[count:] B = B + 1 return B try: N, C, K = raw_input().strip().upper().split() tList = [] for i in range(int(N)): tList.append(int(raw_input().strip())) tList.sort() print count_bus(N, C, K, tList) except EOFError: pass
s296977149
p03785
u112902287
1489370577
Python
Python (3.4.3)
py
Runtime Error
17
3064
173
n = int(input()) a = list(map(int, input().split())) s = 1 while True: if 3*max(a) > 2*sum(a): break else: a.remove(max(a)) s += 1 print(s)
s404324645
p03785
u330205771
1489368375
Python
Python (2.7.6)
py
Runtime Error
1910
137092
372
N, C, K = map(int, raw_input().split()) print(N, C, K) T=[] for i in range(N): T.append(int(raw_input())) print(T) countBus = 1 startTime = T[0] countPeople = 0 for i in range(N-1): print(i,N) countPeople += 1 if (K < (T[i+1] - startTime)) or (C < countPeople): countBus += 1 countPeople = 0 startTime = T[i+1] print countBus
s416135182
p03785
u780663263
1489368145
Python
Python (3.4.3)
py
Runtime Error
207
7072
421
N, C, K = map(int, input().split()) T = [] bus_count = 1 index = 0 for i in range(N): T.append(int(input())) deperture_time = T[0] + K for i, j in enumerate(T, 1): if j > deperture_time: bus_count += 1 index = i deperture_time = j + K continue if i - index == C: bus_count += 1 index = i + 1 deperture_time = T[i+1] + K continue print(bus_count)
s498353364
p03785
u330205771
1489368040
Python
Python (2.7.6)
py
Runtime Error
92
11380
304
N, C, K = map(int, raw_input().split()) T=[] for i in range(N): T.append(raw_input()) countBus = 1 startTime = T[0] countPeople = 0 for i in range(N-1): countPeople += 1 if (K < (T[i+1] - startTime)) or (C < countPeople): countBus += 1 countPeople = 0 startTime = T[i+1] print countBus
s008551122
p03786
u555767343
1594780299
Python
PyPy3 (7.3.0)
py
Runtime Error
111
86400
224
N = int(input()) A = list(map(int, input().split())) import numpy as np A = sorted(A) B = np.cumsum(A) mem = N for i in range(N-1): if 2*B[i] >= A[i+1]: mem = min(i, mem) else: mem = N print(N-mem)
s206249495
p03786
u888092736
1592440158
Python
Python (3.4.3)
py
Runtime Error
35
5048
228
from fractions import gcd from functools import reduce N, K = map(int, input().split()) A = list(map(int, input().split())) g = reduce(gcd, A) if K <= max(A) and K % g == 0: print("POSSIBLE") else: print("IMPOSSIBLE")
s156635805
p03786
u192154323
1591227495
Python
PyPy3 (2.4.0)
py
Runtime Error
161
38256
506
import numpy as np n = int(input()) size_ls = list(map(int, input().split())) size_ls.sort() csum_size = list(np.cumsum(size_ls)) # とりあえず、与えられたインデックスの生き物が全部食べることをできるか返す関数 def isOK(start): res = True for i in range(start, n-1): if not 2 * csum_size[i] >= size_ls[i + 1]: res = False break return res ans = 1 for i in range(n-1): if isOK(i): ans += 1 print(ans)
s392318609
p03786
u474423089
1586562645
Python
Python (3.4.3)
py
Runtime Error
96
14320
237
N=int(input()) A=sorted(list(map(int,input().split(' ')))) acc=[A[0]] for i in A[1:]: acc.append(A[-1]+i) for i in range(N): if acc[i]*2<acc[i+1]: print(N-i-1) break elif i==N-1: print(1) break
s711158221
p03786
u790710233
1585503624
Python
Python (3.4.3)
py
Runtime Error
1764
143544
348
import heapq n = int(input()) A = list(map(int, input().split())) heapq.heapify(A) cnt = 1 prev = heapq.heappop(A) while A: x = heapq.heappop(A) if prev > x: heapq.heappush(A, prev) prev = x continue print(prev, x, A, cnt) if 2*prev < x: cnt = 1 else: cnt += 1 prev += x print(cnt)
s073179046
p03786
u325227960
1584512727
Python
PyPy3 (2.4.0)
py
Runtime Error
256
63984
343
n = int(input()) A = list(map(int,input().split())) m = max(A) B = [0] * (m+1) for i in range(n): B[A[i]] += 1 for i in range(1, m+1): B[i] = B[i-1] + B[i] * i # print(B) ans = 0 for i in range(n): ma = -1 mm = A[i] while mm <= m and ma != mm: ma = mm mm = B[mm] if mm > m: ans += 1 print(ans)
s655920472
p03786
u097317219
1582640594
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38384
258
n=int(input()) a=sorted(list(map(int,input().split()))) flag=0 ans=1 a_cumulative=[0] for i in range(n): flag+=a[i] a_cumulative.append(flag) a.reverse() a_cumulative.reverse() for j in range(n-1): if a[j]<= a_cumulative[j+1]*2: ans+=1 print(ans)
s853672844
p03786
u688375653
1577846341
Python
PyPy3 (2.4.0)
py
Runtime Error
228
63984
437
def two_int(): N, K = map(int, input().split()) return N,K def one_int(): return int(input()) def one_str(): return input() def many_int(): return list(map(int, input().split())) # import sys # input = sys.stdin.readline N=one_int() A=many_int() A=sorted(A) sums_A=list(it.accumulate(A)) for i in range(N-1): if 2*sums_A[i] < A[i+1]: break if len(set(A))==1: print(N) else: print(N-i-1)
s247645446
p03786
u073852194
1575511592
Python
Python (3.4.3)
py
Runtime Error
17
2940
11
5 1 1 1 1 1
s748481918
p03786
u648212584
1568309418
Python
Python (3.4.3)
py
Runtime Error
17
3064
362
import sys input = sys.stdin.readline def main(): N = int(input()) a = list(map(int,input().split())) a.sort(reverse=True) sum_list = [a[0]] for i in range(N-1): sum_list.append(sum_list[i]+a[i+1]) count = 1 sum(a) = A for i in range(N): if (A-sum_list[i])*2 >= a[i]: count += 1 else: break print(count) if __name__ == "__main__": main()
s580469345
p03786
u949186538
1563952073
Python
Python (3.4.3)
py
Runtime Error
157
14776
351
import numpy as np n=int(input()) a=[] for _ in range(n): x=int(input()) a.append(x) a = np.sort(a) a = a[::-1] count = 1 for i in range(1,len(a)): if (a[i]*2 >= a[i-1]): count = count+1 else: sub = np.sum(a[i:]) if (sub*2 >= a[i-1]): count = count+1 else: break print(count)
s057017053
p03786
u474784810
1563951579
Python
Python (3.4.3)
py
Runtime Error
2104
14252
670
x= int(input()) y= input().split() z= list() for i in y: z.append(int(i)) y = z def funct(mons, curr, possible): if not possible: return False if len(mons) == 0: return True if 2*curr >= max(mons): return True smallestMons = min(mons) if 2*curr >= smallestMons: curr = curr + smallestMons mons.remove(smallestMons) if funct(mons, curr, True): return True else: return False else: return False count = 0 for i in range(0, len(y)): tempY = list(y) tempY.remove(y[i]) if funct(tempY, y[i], True): count += 1 print(count)
s190441838
p03786
u474784810
1563951314
Python
Python (3.4.3)
py
Runtime Error
19
5876
663
x= int(input()) x = input() z= list() for i in y: z.append(int(i)) y = z def funct(mons, curr, possible): if not possible: return False if len(mons) == 0: return True if 2*curr >= max(mons): return True smallestMons = min(mons) if 2*curr >= smallestMons: curr = curr + smallestMons mons.remove(smallestMons) if funct(mons, curr, True): return True else: return False else: return False count = 0 for i in range(0, len(y)): tempY = list(y) tempY.remove(y[i]) if funct(tempY, y[i], True): count += 1 print(count)
s401977605
p03786
u543954314
1553362958
Python
Python (3.4.3)
py
Runtime Error
78
14320
182
n = int(input()) a = sorted(list(map(int, input().split())),reverse=True) mintot = sum(a) cnt = 1 for i in range(n): tot -= a[i] if a[i] <= tot*2: break cnt += 1 print(cnt)
s819980082
p03786
u201234972
1549701788
Python
Python (3.4.3)
py
Runtime Error
86
14432
402
from itertools import accumulate N = int( input()) A = list( map( int, input().split())) A.sort() l = -1 r = N-1 B = list( accumulate(A)) while r - l > 1: m = (l+r)//2 # now = sum(A[:m+1]) check = 1 for i in range(m+1,N): if B[i] <= now*2: pass else: check = 0 break if check == 1: r = m else: l = m print(N-r)
s229520430
p03786
u050698451
1531432076
Python
Python (3.4.3)
py
Runtime Error
133
11152
226
N = int(input()) a = input().split() for i in range(0,N): a[i] = int(a[i]) a.sort() t = 0 flag = 1 sum_a = 0 for i in range(0,N): sum_a += a[i] if sum_a*2 < a[i+1]: t = i+1 flag = 0 if flag == 0: break print(N-t)
s092034478
p03786
u112902287
1489372910
Python
Python (3.4.3)
py
Runtime Error
2104
14252
217
n = int(input()) a = list(map(int, input().split())) s = 1 for i in range(n): a.sort() if 3*a[-1] <= 2*a[-2] or 3*a[-1] <= 2*sum(a): a.remove(a[-1]) s = s + 1 else: break print(s)
s645538760
p03787
u905506603
1539899014
Python
Python (2.7.6)
py
Runtime Error
691
33824
750
import sys n, m=map(int, raw_input().split()) adj=[[] for i in range(n+1)] for i in range(m): u, v=map(int, raw_input().split()) adj[u].append(v) adj[v].append(u) isolated_cnt=0 bipartite_cnt=0 other_cnt=0 color=[0]*(n+1) def dfs(cur): for to in adj[cur]: if not color[to]: color[to]=3-color[cur] if not dfs(to): return False else: if color[to]!=3-color[cur]: return False return True for i in range(1, n+1): if adj[i]: if not color[i]: color[i]=1 if dfs(i): bipartite_cnt+=1 else: other_cnt+=1 else: isolated_cnt+=1 print>>sys.stderr, isolated_cnt, bipartite_cnt, other_cnt print isolated_cnt*n*2-isolated_cnt*isolated_cnt+bipartite_cnt*(bipartite_cnt*2+other_cnt)+other_cnt*(bipartite_cnt+other_cnt)
s913024012
p03787
u582577761
1502309278
Python
Python (2.7.6)
py
Runtime Error
688
33868
941
import sys class TailRecurseException: def __init__(self, args, kwargs): self.args = args self.kwargs = kwargs def tail_call_optimized(g): def func(*args, **kwargs): f = sys._getframe() if f.f_back and f.f_back.f_back and f.f_back.f_back.f_code == f.f_code: raise TailRecurseException(args, kwargs) else: while 1: try: return g(*args, **kwargs) except TailRecurseException, e: args = e.args kwargs = e.kwargs func.__doc__ = g.__doc__ return func n,m=map(int,raw_input().split()) vis,ci,cb,cc=[0]*(n+1),0,0,0 g=[[] for i in range(n+1)] def dfs(x,col): if vis[x]: return vis[x]==col vis[x],flag=col,True for i in g[x]: flag&=dfs(i,3-col) return flag for i in range(m): u,v=map(int,raw_input().split()) g[u]+=[v] g[v]+=[u] for i in range(1,n+1): if vis[i]==0: if len(g[i])==0: ci+=1 else: if dfs(i,1): cb+=1 else: cc+=1 print ci*ci+2*ci*(n-ci)+cc*cc+2*cb*cc+2*cb*cb
s652476752
p03787
u582577761
1502308700
Python
Python (3.4.3)
py
Runtime Error
886
31032
442
n,m=map(int,input().split()) vis,ci,cb,cc=[0]*(n+1),0,0,0 g=[[] for i in range(n+1)] def dfs(x,col): if vis[x]: return vis[x]==col vis[x],flag=col,True for i in g[x]: flag&=dfs(i,3-col) return flag for i in range(m): u,v=map(int,input().split()) g[u]+=[v] g[v]+=[u] for i in range(1,n+1): if vis[i]==0: if len(g[i])==0: ci+=1 else: if dfs(i,1): cb+=1 else: cc+=1 print(ci*ci+2*ci*(n-ci)+cc*cc+2*cb*cc+2*cb*cb)
s883734276
p03787
u582577761
1502308570
Python
PyPy3 (2.4.0)
py
Runtime Error
1195
99488
442
n,m=map(int,input().split()) vis,ci,cb,cc=[0]*(n+5),0,0,0 g=[[] for i in range(n+5)] def dfs(x,col): if vis[x]: return vis[x]==col vis[x],flag=col,True for i in g[x]: flag&=dfs(i,3-col) return flag for i in range(m): u,v=map(int,input().split()) g[u]+=[v] g[v]+=[u] for i in range(1,n+1): if vis[i]==0: if len(g[i])==0: ci+=1 else: if dfs(i,1): cb+=1 else: cc+=1 print(ci*ci+2*ci*(n-ci)+cc*cc+2*cb*cc+2*cb*cb)
s530002153
p03787
u582577761
1502308019
Python
PyPy3 (2.4.0)
py
Runtime Error
1090
99488
442
n,m=map(int,input().split()) vis,ci,cb,cc=[0]*(n+1),0,0,0 g=[[] for i in range(n+1)] def dfs(x,col): if vis[x]: return vis[x]==col vis[x],flag=col,True for i in g[x]: flag&=dfs(i,3-col) return flag for i in range(m): u,v=map(int,input().split()) g[u]+=[v] g[v]+=[u] for i in range(1,n+1): if vis[i]==0: if len(g[i])==0: ci+=1 else: if dfs(i,1): cb+=1 else: cc+=1 print(ci*ci+2*ci*(n-ci)+cc*cc+2*cb*cc+2*cb*cb)
s125187888
p03787
u402629484
1489373274
Python
Python (3.4.3)
py
Runtime Error
2105
784500
690
N, M = map(int, input().split()) class U(): def __init__(self): self.live = [True] * (N ** 2) def _connect(self, i, j): if self.live[i]: self.live[i] = False else: self.live[j] = False def connect(self, e1, e2): a1, a2 = e1 b1, b2 = e2 self._connect(a1 * N + b1, a2 * N + b2) self._connect(a1 * N + b2, a2 * N + b1) def count(self): return sum(self.live) u = U() edges = [] for i in range(M): new_edge = list(map(int, input().split())) new_edge[0] -= 1 new_edge[1] -= 1 edges.append(new_edge) for edge in edges: u.connect(new_edge, edge) print(u.count())
s480370953
p03787
u402629484
1489372497
Python
Python (3.4.3)
py
Runtime Error
2105
784500
710
N, M = map(int, input().split()) class UF(): def __init__(self): self.live = [True] * (N ** 2) def _connect(self, i, j): if self.live[i]: self.live[i] = False else: self.live[j] = False def connect(self, e1, e2): a1, a2 = e1 b1, b2 = e2 self._connect(a1 * N + b1, a2 * N + b2) self._connect(a1 * N + b2, a2 * N + b1) def count(self): return sum(self.live) uf = UF() edges = [] for i in range(M): new_edge = list(map(int, input().split())) new_edge[0] -= 1 new_edge[1] -= 1 edges.append(new_edge) for edge in edges: uf.connect(new_edge, edge) print(uf.count()) print(uf.live)
s263294282
p03787
u945080461
1489370093
Python
Python (2.7.6)
py
Runtime Error
216
37672
1277
from sys import stdin from itertools import repeat from collections import deque def main(): n, m = map(int, stdin.readline().split()) dat = map(int, stdin.read().split(), repeat(10, 2 * m)) deg = [0] * n la = [None] * n xt = [0] * (2 * n) for i in xrange(m): ui = i * 2 vi = i * 2 + 1 dat[ui] -= 1 dat[vi] -= 1 u = dat[ui] v = dat[vi] deg[u] += 1 deg[v] += 1 xt[vi] = la[u] la[u] = vi xt[ui] = la[v] la[v] = ui so = tr = lo = 0 q = deque() done = [0] * n pu = q.append po = q.popleft for i in xrange(n): if done[i]: continue pu(i) done[i] = 1 nu = [i] while q: x = po() y = la[x] while y is not None: z = dat[y] if not done[z]: done[z] = 1 pu(z) nu.append(z) y = xt[y] sd = 0 for x in nu: sd += deg[x] if sd == 0: so += 1 elif sd == len(nu) * 2 - 2: tr += 1 else: lo += 1 print lo * lo + lo * tr * 2 + tr * tr * 2 + so * n * 2 - so * so main()
s721852615
p03787
u945080461
1489369865
Python
Python (2.7.6)
py
Runtime Error
190
37672
1238
from sys import stdin from itertools import repeat from collections import deque def main(): n, m = map(int, stdin.readline().split()) dat = map(int, stdin.read().split(), repeat(10, 2 * m)) deg = [0] * n la = [None] * n xt = [0] * (2 * n) for i in xrange(m): ui = i * 2 vi = i * 2 + 1 u = dat[ui] - 1 v = dat[vi] - 1 deg[u] += 1 deg[v] += 1 xt[vi] = la[u] la[u] = vi xt[ui] = la[v] la[v] = ui so = tr = lo = 0 q = [] done = [0] * n pu = q.append po = q.pop for i in xrange(n): if done[i]: continue pu(i) done[i] = 1 nu = [i] while q: x = po() y = la[x] while y is not None: z = dat[y] - 1 if not done[z]: done[z] = 1 pu(z) nu.append(z) y = xt[y] sd = 0 for x in nu: sd += deg[x] if sd == 0: so += 1 elif sd == len(nu) * 2 - 2: tr += 1 else: lo += 1 print lo * lo + lo * tr * 2 + tr * tr * 2 + so * n * 2 - so * so main()
s618778487
p03788
u582577761
1502320952
Python
PyPy3 (2.4.0)
py
Runtime Error
238
67120
444
n,k=map(int,input().split()) s=list(input())*2 p=['A' if s[i]=='B' else 'B' for i in range(n)]*2 head,tail=0,n for i in range(2*n): if s[0]=='A': s[0],p[0]='B','A' else: s,p=p,s head+=1 s[tail],p[tail]='A','B' tail+=1 if i==k-1: print(''.join(s[head:tail])) break else: if n%2==1 and k%2==1: if s[0]=='A': s[0],p[0]='B','A' else: s,p=p,s head+=1 s[tail],t[tail]='A','B' tail+=1 print(''.join(s[head:tail]))
s753003657
p03788
u452725238
1489378034
Python
PyPy2 (5.6.0)
py
Runtime Error
36
28012
216
import sys import math def ok(n,k): if k<0: return 0 v = 9*(n+k) d = 0 while v > 0: d += v%10 v /= 10 return 9*k>=d N=input() K=1<<20 for i in range(19,-1,-1): if ok(N,K-(1<<i)): K -= 1<<i print K
s138985172
p03788
u515802486
1489373707
Python
Python (3.4.3)
py
Runtime Error
2104
7076
1167
import sys INF = 10**9+7 stdin = sys.stdin def na(): return map(int, stdin.readline().split()) def nal(): return list(map(int, stdin.readline().split())) def ns(): return stdin.readline().strip() def nsl(): return list(stdin.readline().strip()) def ni(): return int(stdin.readline()) n, k = nal() s = nsl() st = s[0] lst = [] c=1 for i in range(1, n): if(st == s[i]): c += 1 else: lst.append(c) c = 1 st = s[i] lst.append(c) st = s[0] for i in range(k): if(st == 'A'): if(lst[0] == 1): lst.pop(0) lst[0] += 1 else: lst.insert(0, 1) lst[1] -= 1 st = 'B' else: lst.insert(0, 1) for j in range(len(lst)//2): t = j*2+1 lst[t] = lst[t] + lst[t+1] - 2 lst[t+1] = 2 if(len(lst) % 2 == 1): lst[-1] -= 1 else: lst[-2] = lst[-1] + 1 lst.pop(-1) st = 'A' st = s[0] ans = [] for i in range(len(lst)): for j in range(lst[i]): ans.append(st) if(st == 'A'): st = 'B' else: st = 'A' print("".join(ans))
s679753525
p03788
u515802486
1489373626
Python
Python (3.4.3)
py
Runtime Error
2104
7084
1376
import sys INF = 10**9+7 stdin = sys.stdin def na(): return map(int, stdin.readline().split()) def nal(): return list(map(int, stdin.readline().split())) def ns(): return stdin.readline().strip() def nsl(): return list(stdin.readline().strip()) def ni(): return int(stdin.readline()) def func(n, k, s): st = s[0] lst = [] c=1 for i in range(1, n): if(st == s[i]): c += 1 else: lst.append(c) c = 1 st = s[i] lst.append(c) st = s[0] for i in range(k): if(st == 'A'): if(lst[0] == 1): lst.pop(0) lst[0] += 1 else: lst.insert(0, 1) lst[1] -= 1 st = 'B' else: lst.insert(0, 1) for j in range(len(lst)//2): t = j*2+1 lst[t] = lst[t] + lst[t+1] - 2 lst[t+1] = 2 if(len(lst) % 2 == 1): lst[-1] -= 1 else: lst[-2] = lst[-1] + 1 lst.pop(-1) st = 'A' st = s[0] ans = [] for i in range(len(lst)): for j in range(lst[i]): ans.append(st) if(st == 'A'): st = 'B' else: st = 'A' print("".join(ans)) n, k = nal() s = nsl() func(n, k, s)
s486905542
p03788
u945080461
1489373463
Python
Python (2.7.6)
py
Runtime Error
123
6684
1952
from collections import deque def main(): n, k = map(int, raw_input().split()) s = raw_input().strip() ans = deque(list(s)) if n == 1: if k % 2: print 'A' if s[0] == 'B' else 'B' else: print s[0] return f = True for i in xrange(400020): if i >= k: if f: print ''.join(list(ans)) else: print ''.join('A' if x == 'B' else 'B' for x in ans) break if (ans[0] == 'A') == f: ans[0] = 'B' if f else 'A' else: f = not f ans.popleft() ans.append('A' if f else 'B') else: k -= 400020 k %= 2 if not f: ans = ['B' if x == 'A' else 'A' for x in ans] ans = deque(ans) if not k: if ans[0] == 'A': ans[0] = 'B' else: ans[0] = 'A' print ''.join(ans) main() from collections import deque def main(): n, k = map(int, raw_input().split()) s = raw_input().strip() ans = deque(list(s)) if n == 1: if k % 2: print 'A' if s[0] == 'B' else 'B' else: print s[0] return f = True for i in xrange(400020): if i >= k: if f: print ''.join(list(ans)) else: print ''.join('A' if x == 'B' else 'B' for x in ans) break if (ans[0] == 'A') == f: ans[0] = 'B' if f else 'A' else: f = not f ans.popleft() ans.append('A' if f else 'B') else: k -= 400020 k %= 2 if not f: ans = ['B' if x == 'A' else 'A' for x in ans] ans = deque(ans) if not k: if ans[0] == 'A': ans[0] = 'B' else: ans[0] = 'A' print ''.join(ans) main()
s308671418
p03788
u945080461
1489373293
Python
Python (2.7.6)
py
Runtime Error
219
6684
1944
from collections import deque def main(): n, k = map(int, raw_input().split()) s = raw_input().strip() ans = deque(list(s)) if n == 1: if k % 2: print 'A' if s[0] == 'B' else 'B' else: print s[0] return f = True for i in xrange(800020): if i >= k: if f: print ''.join(list(ans)) else: print ''.join('A' if x == 'B' else 'B' for x in ans) break if (ans[0] == 'A') == f: ans[0] = 'B' if f else 'A' else: f = not f ans.popleft() ans.append('A' if f else 'B') else: k -= 800020 k %= 2 if not f: ans = ['B' if x == 'A' else 'A' for x in ans] ans = deque(ans) if k: if ans[0] == 'A': ans[0] = 'B' else: ans[0] = 'A' print ''.join(ans) main() from collections import deque def main(): n, k = map(int, raw_input().split()) s = raw_input().strip() ans = deque(list(s)) if n == 1: if k % 2: print 'A' if s[0] == 'B' else 'B' else: print s[0] return f = True for i in xrange(800020): if i >= k: if f: print ''.join(list(ans)) else: print ''.join('A' if x == 'B' else 'B' for x in ans) break if (ans[0] == 'A') == f: ans[0] = 'B' if f else 'A' else: f = not f ans.popleft() ans.append('A' if f else 'B') else: k -= 800020 k %= 2 if not f: ans = ['B' if x == 'A' else 'A' for x in ans] ans = deque(ans) if k: if ans[0] == 'A': ans[0] = 'B' else: ans[0] = 'A' print ''.join(ans) main()
s796672093
p03789
u021034020
1580346276
Python
PyPy3 (2.4.0)
py
Runtime Error
2122
311804
387
# coding: utf-8 # Your code here def sum(x): if x<10: return x ans=divmod(x,10) return ans[1]+sum(ans[0]) x=input() y=int(x) y*=9 z=int(100000) z*=z i=y%z i=z-i i+=z minu=z while minu>=1: if i<minu: minu=divmod(minu,10)[0] continue if sum(y+i-minu)<=(i-minu): i-=minu else: minu=divmod(minu,10)[0] print(divmod((i+8),9)[0])