message
stringlengths
2
65.1k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
0
108k
cluster
float64
14
14
__index_level_0__
int64
0
217k
Provide a correct Python 3 solution for this coding contest problem. There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will a...
instruction
0
27,222
14
54,444
"Correct Solution: ``` n=int(input()) s=input() cnt=s[1:].count('E') mi=cnt for i in range(1,n): if s[i]=='E': cnt-=1 if s[i-1]=='W': cnt+=1 mi=min(mi,cnt) print(mi) ```
output
1
27,222
14
54,445
Provide a correct Python 3 solution for this coding contest problem. There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will a...
instruction
0
27,223
14
54,446
"Correct Solution: ``` N = int(input()) S = input() r = 0 for w in S[1:]: if w == 'E': r += 1 m = r for i in range(1,len(S)): if S[i] == 'E': r -= 1 if S[i-1] == 'W': r += 1 if r < m: m = r print(m) ```
output
1
27,223
14
54,447
Provide a correct Python 3 solution for this coding contest problem. There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will a...
instruction
0
27,224
14
54,448
"Correct Solution: ``` n = int(input()) s = input() ans = 10**9 l = 0 r = 0 L = [0] R = [0] for i in range(n - 1): l += s[i].count('W') r += s[-i - 1].count('E') L.append(l) R.append(r) for l, r in zip(L, R[::-1]): ans = min(ans, l + r) print(ans) ```
output
1
27,224
14
54,449
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is faci...
instruction
0
27,226
14
54,452
Yes
output
1
27,226
14
54,453
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is faci...
instruction
0
27,227
14
54,454
Yes
output
1
27,227
14
54,455
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is faci...
instruction
0
27,228
14
54,456
Yes
output
1
27,228
14
54,457
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is faci...
instruction
0
27,229
14
54,458
Yes
output
1
27,229
14
54,459
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is faci...
instruction
0
27,230
14
54,460
No
output
1
27,230
14
54,461
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is faci...
instruction
0
27,231
14
54,462
No
output
1
27,231
14
54,463
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is faci...
instruction
0
27,232
14
54,464
No
output
1
27,232
14
54,465
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is faci...
instruction
0
27,233
14
54,466
No
output
1
27,233
14
54,467
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has recently got a job as a cashier at a local store. His day at work is L minutes long. Vasya has already memorized n regular customers, the i-th of which comes after t_{i} minutes after the beginning of the day, and his service consu...
instruction
0
27,413
14
54,826
Tags: implementation Correct Solution: ``` n, L, a = map(int, input().split()) s = 0 p = 0 for i in range(n): t, l = map(int, input().split()) s += (t - p) // a p = l + t s += (L - p) // a print(s) ```
output
1
27,413
14
54,827
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has recently got a job as a cashier at a local store. His day at work is L minutes long. Vasya has already memorized n regular customers, the i-th of which comes after t_{i} minutes after the beginning of the day, and his service consu...
instruction
0
27,414
14
54,828
Tags: implementation Correct Solution: ``` n,L,div=list(map(int,input().split())) ans=0 x=[[0,0]] for o in range(n): a,b=list(map(int,input().split())) x.append([a,b+a]) x.append([L,L]) for i in range(1,len(x)): ans=ans+(x[i][0]-x[i-1][1])//div print(ans) ```
output
1
27,414
14
54,829
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has recently got a job as a cashier at a local store. His day at work is L minutes long. Vasya has already memorized n regular customers, the i-th of which comes after t_{i} minutes after the beginning of the day, and his service consu...
instruction
0
27,415
14
54,830
Tags: implementation Correct Solution: ``` a,b,c=map(int,input().split()) i=0 x=0 z=0 while i<a: p,q=map(int,input().split()) z+=(p-x)//c x=p+q i+=1 z+=(b-x)//c print (z) ```
output
1
27,415
14
54,831
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has recently got a job as a cashier at a local store. His day at work is L minutes long. Vasya has already memorized n regular customers, the i-th of which comes after t_{i} minutes after the beginning of the day, and his service consu...
instruction
0
27,416
14
54,832
Tags: implementation Correct Solution: ``` n,l,k=map(int,input().split()) c=d=0 for i in range(n): p,q=map(int,input().split()) c+=int(abs(p-d)/k) d=p+q if d<l: c+=int((l-d)/k) print(c) ```
output
1
27,416
14
54,833
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has recently got a job as a cashier at a local store. His day at work is L minutes long. Vasya has already memorized n regular customers, the i-th of which comes after t_{i} minutes after the beginning of the day, and his service consu...
instruction
0
27,417
14
54,834
Tags: implementation Correct Solution: ``` n, l, a = list(map(int, input().split())) arrives = [0] * n takes = [0] * n for i in range(n): arrives[i], takes[i] = list(map(int, input().split())) cur = 0 ans = 0 for i in range(n): gap = arrives[i] - cur ans += gap // a cur = arrives[i] + takes[i] ans += (l - cur) //...
output
1
27,417
14
54,835
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has recently got a job as a cashier at a local store. His day at work is L minutes long. Vasya has already memorized n regular customers, the i-th of which comes after t_{i} minutes after the beginning of the day, and his service consu...
instruction
0
27,418
14
54,836
Tags: implementation Correct Solution: ``` n,L,a=map(int,input().split()) c=0 emp=[] for i in range(n): l,t=map(int,input().split()) if emp: c+=(l-(emp[-1][0]+emp[-1][1]))//a else: c+=l//a emp.append([l,t]) if emp: c+=(L-(emp[-1][0]+emp[-1][1]))//a else: c+=L//a print(c) ```
output
1
27,418
14
54,837
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has recently got a job as a cashier at a local store. His day at work is L minutes long. Vasya has already memorized n regular customers, the i-th of which comes after t_{i} minutes after the beginning of the day, and his service consu...
instruction
0
27,419
14
54,838
Tags: implementation Correct Solution: ``` import sys lines = iter(sys.stdin) def nexts(): return next(lines) def nextint(): return int(nexts()) def snexts(): return next(lines).split(' ') def snextint(): return map(int, snexts()) n, l, a = snextint() cust = [] cust.append((0, 0)) for _ in range(...
output
1
27,419
14
54,839
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has recently got a job as a cashier at a local store. His day at work is L minutes long. Vasya has already memorized n regular customers, the i-th of which comes after t_{i} minutes after the beginning of the day, and his service consu...
instruction
0
27,420
14
54,840
Tags: implementation Correct Solution: ``` n,l,m=map(int,input().split()) a=[] for i in range(n): x,y=map(int,input().split()) a.append([x,x+y]) s=0 b=0 for i in range(n): z=a[i][0]-b s+=z//m b=a[i][1] s+=(l-b)//m print(s) ```
output
1
27,420
14
54,841
Provide tags and a correct Python 3 solution for this coding contest problem. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats th...
instruction
0
27,445
14
54,890
Tags: dp, implementation Correct Solution: ``` n,k=map(int,input().split()) group=list(map(int,input().split())) available=[[k,1] for i in range(k+1)] center=(k+1)//2 def calc(center,row,col,num): end_col=col+num-1 distance=abs(center-row)*num if col>=center: distance+=(col-center)*num+(num-1)*num//2 elif e...
output
1
27,445
14
54,891
Provide tags and a correct Python 3 solution for this coding contest problem. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats th...
instruction
0
27,446
14
54,892
Tags: dp, implementation Correct Solution: ``` #10B def solve(): # n requests, k rows and seats on each row n, k = map(int, input().split()) # succesive seats group = map(int, input().split()) # make map with available seats available = [[k, 1][:] for i in range(k + 1)] center = (k + 1) // 2 # for e...
output
1
27,446
14
54,893
Provide tags and a correct Python 3 solution for this coding contest problem. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats th...
instruction
0
27,447
14
54,894
Tags: dp, implementation Correct Solution: ``` def solve(): n, k = map(int, input().split()) group = map(int, input().split()) available = [[k, 1][:] for _ in range(k + 1)] center = (k + 1) // 2 for m in group: closest, best_row, best_col = 10000, -1, -1 for row in range(1, k + 1): ...
output
1
27,447
14
54,895
Provide tags and a correct Python 3 solution for this coding contest problem. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats th...
instruction
0
27,448
14
54,896
Tags: dp, implementation Correct Solution: ``` n,k=list(map(int,input().split())) a=list(map(int,input().split())) b=[-1]*k for m in a: c=[-1] for x in range(1,k+1): j=x-1 if b[j]==-1: yl=k//2+1-m//2 yr=yl+m-1 d=abs(x-k//2-1)*m+(2*(k//2+1)-(yl+min(yr,k//2+1)))...
output
1
27,448
14
54,897
Provide tags and a correct Python 3 solution for this coding contest problem. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats th...
instruction
0
27,449
14
54,898
Tags: dp, implementation Correct Solution: ``` import math from itertools import accumulate R = lambda: map(int, input().split()) n, k = R() xc = yc = (k + 1) // 2 row = list(accumulate(abs(j - yc) for j in range(k + 1))) dp = [[k + 1 - j for j in range(k + 1)] for _ in range(k + 1)] for l in R(): xt, yt, c = -1, ...
output
1
27,449
14
54,899
Provide tags and a correct Python 3 solution for this coding contest problem. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats th...
instruction
0
27,450
14
54,900
Tags: dp, implementation Correct Solution: ``` #10B def solve(): # n - requests, k - rows and seats on each row n, k = map(int, input().split()) #We group succesive seats: group = map(int, input().split()) #Now, we elaborate a map with available seats available = [[k, 1][:] for i in range(k + 1)] cen...
output
1
27,450
14
54,901
Provide tags and a correct Python 3 solution for this coding contest problem. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats th...
instruction
0
27,451
14
54,902
Tags: dp, implementation Correct Solution: ``` import math import sys from bisect import bisect_right, bisect_left, insort_right from collections import Counter, defaultdict from heapq import heappop, heappush from itertools import accumulate, permutations, combinations from sys import stdout R = lambda: map(int, inpu...
output
1
27,451
14
54,903
Provide tags and a correct Python 3 solution for this coding contest problem. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats th...
instruction
0
27,452
14
54,904
Tags: dp, implementation Correct Solution: ``` import sys # import logging # logging.root.setLevel(level=logging.DEBUG) # logging.root.setLevel(level=logging.INFO) import re from math import ceil length,size = map(int,sys.stdin.readline().split()) peoples = map(int,sys.stdin.readline().split()) has_occupied = [[True]+...
output
1
27,452
14
54,905
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to ...
instruction
0
27,453
14
54,906
Yes
output
1
27,453
14
54,907
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to ...
instruction
0
27,454
14
54,908
Yes
output
1
27,454
14
54,909
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to ...
instruction
0
27,455
14
54,910
Yes
output
1
27,455
14
54,911
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to ...
instruction
0
27,456
14
54,912
Yes
output
1
27,456
14
54,913
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to ...
instruction
0
27,457
14
54,914
No
output
1
27,457
14
54,915
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to ...
instruction
0
27,458
14
54,916
No
output
1
27,458
14
54,917
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to ...
instruction
0
27,459
14
54,918
No
output
1
27,459
14
54,919
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to ...
instruction
0
27,460
14
54,920
No
output
1
27,460
14
54,921
Provide tags and a correct Python 3 solution for this coding contest problem. You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses ei...
instruction
0
27,545
14
55,090
Tags: brute force, data structures, implementation Correct Solution: ``` a=int(input()) for i in range(a): n,m,k=map(int,input().split()) z=list(map(int,input().split())) if(m-1<=k): ans1=z[::-1] print(max(max(z[0:m]),max(ans1[0:m]))) else: alpha=[] for i in...
output
1
27,545
14
55,091
Provide tags and a correct Python 3 solution for this coding contest problem. You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses ei...
instruction
0
27,546
14
55,092
Tags: brute force, data structures, implementation Correct Solution: ``` from sys import stdin,stdout from math import gcd,sqrt from collections import deque input=stdin.readline R=lambda:map(int,input().split()) I=lambda:int(input()) S=lambda:input().rstrip('\n') L=lambda:list(R()) P=lambda x:stdout.write(x) lcm=lambd...
output
1
27,546
14
55,093
Provide tags and a correct Python 3 solution for this coding contest problem. You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses ei...
instruction
0
27,547
14
55,094
Tags: brute force, data structures, implementation Correct Solution: ``` for _ in range(int(input())): n,m,k = map(int,input().split()) a = list(map(int,input().split())) mn = min(k,m-1) x,y = m-1,n-m ans = -1 for i in range(mn+1): val = float('inf') for j in range(m-mn): ...
output
1
27,547
14
55,095
Provide tags and a correct Python 3 solution for this coding contest problem. You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses ei...
instruction
0
27,548
14
55,096
Tags: brute force, data structures, implementation Correct Solution: ``` def Input(): tem = input().split() ans = [] for it in tem: ans.append(int(it)) return ans T = Input()[0] for t in range(T): n,m,k = Input() a = Input() if k+1>=m: l, r = 0, n-m ans = -1000000000...
output
1
27,548
14
55,097
Provide tags and a correct Python 3 solution for this coding contest problem. You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses ei...
instruction
0
27,549
14
55,098
Tags: brute force, data structures, implementation Correct Solution: ``` for _ in range(int(input())) : n, m, k = map(int, input().split()) a = list(map(int, input().split())) mx = -1 if k >= m : for i in range(n) : if i < m or i > n - m - 1 : mx = max(mx, a[i]) ...
output
1
27,549
14
55,099
Provide tags and a correct Python 3 solution for this coding contest problem. You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses ei...
instruction
0
27,550
14
55,100
Tags: brute force, data structures, implementation Correct Solution: ``` T = int(input()) for cs in range(T): n, m, k = map(int,input().split()) a = list(map(int,input().split())) k = min(k,m-1) # i only need to persuade infront of me p = m-k mx = 0 for dummy in range(10): for i in range...
output
1
27,550
14
55,101
Provide tags and a correct Python 3 solution for this coding contest problem. You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses ei...
instruction
0
27,551
14
55,102
Tags: brute force, data structures, implementation Correct Solution: ``` def chek(x,li,l): # print(li,x,l) mn=max(li[0],li[l-1]) for i in range(x+1): mx=max(li[i],li[l+i-1]) mn=min(mn,mx) # print(mn) return mn t=int(input()) for _ in range(t): n,m,k=map(int,input().split()) ar=list(map(int,input().split()...
output
1
27,551
14
55,103
Provide tags and a correct Python 3 solution for this coding contest problem. You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses ei...
instruction
0
27,552
14
55,104
Tags: brute force, data structures, implementation Correct Solution: ``` #------------------------------warmup---------------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() ...
output
1
27,552
14
55,105
Provide tags and a correct Python 3 solution for this coding contest problem. In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β€” how many people who are taller than him/her and sta...
instruction
0
27,617
14
55,234
Tags: constructive algorithms, greedy, sortings Correct Solution: ``` n = int(input()) arr = [] for i in range(n): a,b = list(map(str,input().split())) b = int(b) arr.append([b,a]) arr.sort() ans = [] for i in arr: if i[0]>len(ans): print(-1) exit() ans.insert(i[0],(i[1],n)) n-=...
output
1
27,617
14
55,235
Provide tags and a correct Python 3 solution for this coding contest problem. In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β€” how many people who are taller than him/her and sta...
instruction
0
27,618
14
55,236
Tags: constructive algorithms, greedy, sortings Correct Solution: ``` #!/usr/bin/python3 n = int(input()) a = [] for i in range(n): s, c = input().split() a.append((s, int(c))) a.sort(key=lambda x: x[1]) ans = [] for i in range(n): if len(ans) < a[i][1]: print(-1) exit(0) ans.insert(a[...
output
1
27,618
14
55,237
Provide tags and a correct Python 3 solution for this coding contest problem. In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β€” how many people who are taller than him/her and sta...
instruction
0
27,619
14
55,238
Tags: constructive algorithms, greedy, sortings Correct Solution: ``` n = int(input()) a = sorted([list(map(lambda x: x if x[0] >= 'a' and x[0] <= 'z' else int(x), input().split()))[::-1] for i in range(n)]) fl = 1 ans = [] for i in range(len(a)): v, name = a[i] if i == 0: if v > 0: fl = 0 ...
output
1
27,619
14
55,239
Provide tags and a correct Python 3 solution for this coding contest problem. In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β€” how many people who are taller than him/her and sta...
instruction
0
27,620
14
55,240
Tags: constructive algorithms, greedy, sortings Correct Solution: ``` n = int(input()) a = [] for _ in range(n): x = input().split() a.append((x[0], int(x[1]))) a.sort(key=lambda x: x[1]) ans = [] for x in a: if x[1] > len(ans): print(-1) exit() ans.insert(x[1], (x[0], n)) n -= 1 for...
output
1
27,620
14
55,241
Provide tags and a correct Python 3 solution for this coding contest problem. In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β€” how many people who are taller than him/her and sta...
instruction
0
27,621
14
55,242
Tags: constructive algorithms, greedy, sortings Correct Solution: ``` n = int(input()) arr = [input().split() for _ in range(n)] arr = [[int(arr[i][1]), arr[i][0]] for i in range(n)] arr.sort() res = [] for i in range(n): res.append(i - arr[i][0]) if res[i] < 0: print(-1) exit() for j in range(i): if res[j] >=...
output
1
27,621
14
55,243
Provide tags and a correct Python 3 solution for this coding contest problem. In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β€” how many people who are taller than him/her and sta...
instruction
0
27,622
14
55,244
Tags: constructive algorithms, greedy, sortings Correct Solution: ``` n=int(input()) arr=[] for i in range(n): a,b=input().split() arr.append([a,int(b)]) arr.sort(key=lambda x:x[1]) ans=[] #print(arr) for x in arr: if x[1]>len(ans): print(-1) exit() ans.insert(x[1],(x[0],n)) n-=1 for x in ans:print(x[...
output
1
27,622
14
55,245
Provide tags and a correct Python 3 solution for this coding contest problem. In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β€” how many people who are taller than him/her and sta...
instruction
0
27,623
14
55,246
Tags: constructive algorithms, greedy, sortings Correct Solution: ``` import sys n = int(input()) person = [] for i in range(n): person.append(input().split()) person.sort(key = lambda x: int(x[1])) high = 10 ** 9 low = 1 cntHigh = 0 for i in range(n): dif = int(person[i][1]) - cntHigh for j in range(i...
output
1
27,623
14
55,247