message
stringlengths
2
39.6k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
219
108k
cluster
float64
11
11
__index_level_0__
int64
438
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions.
instruction
0
87,594
11
175,188
Tags: implementation Correct Solution: ``` from collections import defaultdict as dd import math import heapq def nn(): return int(input()) def li(): return list(input()) def mi(): return map(int, input().split()) def lm(): return list(map(int, input().split())) n, p=mi() l=lm() pq=[] done=0 intints=[] for i in range(min(p,n)): heapq.heappush(pq, l[i]) intints.append((0,l[i])) currtask=min(p,n) interesting=0 donetimes=[] while done<n: nextdone=heapq.heappop(pq) done+=1 currtime=nextdone donetimes.append(currtime) if currtask<len(l): heapq.heappush(pq,l[currtask]+currtime) intints.append((currtime,l[currtask]+currtime)) currtask+=1 percenttimes=[] for i in range(n): percenttimes.append((math.floor(100*(i+1)/n+1/2),donetimes[i])) #print(percenttimes) for lower, upper in intints: for j in range(1,len(percenttimes)): lowertime=percenttimes[j-1][1] uppertime=percenttimes[j][1] percent=percenttimes[j-1][0] values=upper-lower #print(values,percent) if percent in range(1,values+1): time=lower+percent-1/2 if time>lowertime and time<uppertime: interesting+=1 break print(interesting) #print(donetimes, intints) ```
output
1
87,594
11
175,189
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions.
instruction
0
87,595
11
175,190
Tags: implementation Correct Solution: ``` n,k=map(int,input().split()) li=list(map(int,input().split())) k=min(n,k) res=li[:k] pro=li[:k] for i in range(k-1,-1,-1): li.pop(i) don=[] for i in range(k): don.append(0) t=0 d=0 m=0 c=0 used=[False]*n p=list(range(k)) while li or res: t1=t pd=[] for i in don: pd.append(i) t=min(res)+t1 for i in range(len(don)): don[i]=don[i]+t-t1 for i in range(len(res)): res[i]=pro[i]-don[i] for i in range(len(don)): if pd[i]<d<=don[i] and not used[p[i]]: c+=1 used[p[i]]='True' z=0 for i in range(len(res)-1,-1,-1): if res[i]==0: z+=1 pro.pop(i) res.pop(i) don.pop(i) for j in range(i,k-1): p[j]=p[j+1] m+=z d=int(100*(m/n)+0.5) while(z): z-=1 if li: pro.append(li[0]) res.append(li[0]) don.append(0) p[k-1-z]=n-len(li) li.pop(0) print(c) ```
output
1
87,595
11
175,191
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions.
instruction
0
87,596
11
175,192
Tags: implementation Correct Solution: ``` n,k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] k = min(k, n) p = a[:k];q = a[:k];r = list(range(k)) m = 0;j = k ans = 0 used = [False]*n while True: d = int(100 * m / n + 0.5) for i in range(k): if p[i]==0: continue p[i]-=1 if q[i]-p[i]==d and not used[r[i]]: ans += 1 used[r[i]] = True if p[i] == 0: m += 1 if j == n: continue p[i] = a[j];q[i] = a[j];r[i] = j j += 1 if p.count(0) == k: break print(ans) ```
output
1
87,596
11
175,193
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions.
instruction
0
87,597
11
175,194
Tags: implementation Correct Solution: ``` #!/usr/bin/env python3 import math from collections import deque n, k = map(int, input().split()) q = deque(list(map(int, input().split()))) progress = 0 d = 0 interesting = 0 jobs = [] def minpass(jobs): return list(map(lambda x: [x[0], x[1]+1, x[2]], jobs)) def rmdone(jobs): cur_jobs = list(filter(lambda x: x[0]>x[1], jobs)) done = len(jobs) - len(cur_jobs) return (cur_jobs, done) while len(jobs) > 0 or len(q) > 0: for j in range(len(jobs)): if jobs[j][1] == d and not jobs[j][2]: interesting += 1 jobs[j][2] = True jobs, done = rmdone(jobs) progress += done d = max(math.floor(100*progress/n + 0.5), 0.00001) while len(q) and len(jobs) < k: jobs.append([q.popleft(),0,False]) jobs = minpass(jobs) print(interesting) ```
output
1
87,597
11
175,195
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions.
instruction
0
87,598
11
175,196
Tags: implementation Correct Solution: ``` n, k = map(int, input().split()) a = list(map(int, input().split())) processes = [0] * k start = [None] * n finish = [None] * n for i in range(n): first_free = min(enumerate(processes), key=lambda x: x[1])[0] start[i] = processes[first_free] finish[i] = processes[first_free] + a[i] processes[first_free] = finish[i] finish.sort() finished = [0] * n * 151 j = 0 for i in range(n * 151): finished[i] = finished[i - 1] while finish[j] <= i and j < n - 1: if finish[j] == i: finished[i] += 1 j += 1 res = 0 for i in range(n): is_good = False for j in range(a[i]): time = start[i] + j m = finished[time] if j + 1 == int(100 * m / n + 0.5): res += 1 break print(res) ```
output
1
87,598
11
175,197
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions.
instruction
0
87,599
11
175,198
Tags: implementation Correct Solution: ``` nums = list(map(int, input().split())) n, k = nums[0], nums[1] solved = 0 tests = list(map(int, input().split())) res = 0 machines_remain = [] machines_now = [] machines_interes = [] for foo in range(k): machines_remain.append(0) machines_now.append(0) machines_interes.append(0) d = 0 while True: if solved < n: m = 0 while m < len(machines_remain): if machines_remain[m] == 0 and len(tests) > 0: machines_remain[m] = tests[0] machines_now[m] = 0 machines_interes[m] = 0 tests.pop(0) if machines_remain[m] > 0: machines_now[m] += 1 if (machines_now[m] == d) and (machines_interes[m]==0): machines_interes[m] = 1 res += 1 machines_remain[m] -= 1 if machines_remain[m] == 0: machines_now[m] = 0 solved += 1 m += 1 d = int(100 * solved / n + 0.5) else: print(res) break ```
output
1
87,599
11
175,199
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions.
instruction
0
87,600
11
175,200
Tags: implementation Correct Solution: ``` # https://codeforces.com/problemset/problem/1121/C import heapq n, k = map(int, input().split()) task = list(map(int, input().split())) a = [[i, x] for i, x in enumerate(task)] start_ = [0] * n end_ = [0] * n Q = [] for i in range(k): if len(a) > 0: ind, length = a.pop(0) start_[ind] = 0 end_[ind] = length heapq.heappush(Q, length) while len(Q) > 0: end_t = heapq.heappop(Q) if len(a) > 0: ind, length = a.pop(0) start_[ind] = end_t end_[ind] = end_t + length heapq.heappush(Q, end_[ind]) end_e = sorted(end_) d = {} count = 0 for i, e in enumerate(end_e): count += 1 d[e] = int(100 * count / n + 0.5) special = 0 for i in range(n): flg = False arr = [] for j, end_t in enumerate(end_e[:-1]): if end_t >= end_[i]:break if end_e[j+1] > start_[i]: arr.append(end_t) arr.append(end_[i]) if len(arr) > 1: for x, y in zip(arr[:-1], arr[1:]): if x-start_[i] < d[x] and d[x] <= y - start_[i]: flg = True break if flg == True: special += 1 print(special)#32 100 33 1 ```
output
1
87,600
11
175,201
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` import sys, os, io def rs(): return sys.stdin.readline().rstrip() def ri(): return int(sys.stdin.readline()) def ria(): return list(map(int, sys.stdin.readline().split())) def ws(s): sys.stdout.write(s + '\n') def wi(n): sys.stdout.write(str(n) + '\n') def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n') import math,datetime,functools,itertools,operator,bisect,fractions,statistics from collections import deque,defaultdict,OrderedDict,Counter from fractions import Fraction from decimal import Decimal from sys import stdout from heapq import heappush, heappop, heapify ,_heapify_max,_heappop_max,nsmallest,nlargest def main(): # mod=1000000007 # InverseofNumber(mod) # InverseofFactorial(mod) # factorial(mod) starttime=datetime.datetime.now() if(os.path.exists('input.txt')): sys.stdin = open("input.txt","r") sys.stdout = open("output.txt","w") tc=1 for _ in range(tc): n,k=ria() k=min(n,k) a=ria() rn=a[:k] arn=[0]*k m=0 j=k d=0 ans=0 ignore={} sol={} prevd=0 while m<n: for i in range(k): if i not in ignore: arn[i]+=1 if arn[i]==prevd and i not in sol: # print(arn[i]) ans+=1 sol[i]=1 if arn[i]==rn[i] : m+=1 arn[i]=0 if i in sol: del sol[i] d=math.floor(((100*m)/n)+0.5) if j<n: rn[i]=a[j] j+=1 else: ignore[i]=1 prevd=d print(ans) #<--Solving Area Ends endtime=datetime.datetime.now() time=(endtime-starttime).total_seconds()*1000 if(os.path.exists('input.txt')): print("Time:",time,"ms") class FastReader(io.IOBase): newlines = 0 def __init__(self, fd, chunk_size=1024 * 8): self._fd = fd self._chunk_size = chunk_size self.buffer = io.BytesIO() def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self, size=-1): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() class FastWriter(io.IOBase): def __init__(self, fd): self._fd = fd self.buffer = io.BytesIO() self.write = self.buffer.write def flush(self): os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class FastStdin(io.IOBase): def __init__(self, fd=0): self.buffer = FastReader(fd) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") class FastStdout(io.IOBase): def __init__(self, fd=1): self.buffer = FastWriter(fd) self.write = lambda s: self.buffer.write(s.encode("ascii")) self.flush = self.buffer.flush if __name__ == '__main__': sys.stdin = FastStdin() sys.stdout = FastStdout() main() ```
instruction
0
87,601
11
175,202
Yes
output
1
87,601
11
175,203
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` n,k=map(int,input().split()) a=list(map(int,input().split())) j=0 p=[[0,0]]*k;sol=set();testing=set();test={} t=0;sub=0;b=False;an=0 while 1: if sub==n: break for i in range(k): if p[i][0]==0: if j<n: #continue #print(p) p[i]=[a[j],j]; testing.add(j); test[j]=1;j+=1 else: p[i][0]-=1 test[p[i][1]]+=1 if p[i][0]==0: #print(t,i) if p[i][1] not in testing: continue sub+=1 #print(testing) testing.remove(p[i][1]) test[p[i][1]]=-1 for i in range(k): if p[i][0]==0: if j<n: #continue #print(p) p[i]=[a[j],j]; testing.add(j); test[j]=1;j+=1 #print(t,testing) t+=1 if t==49: pass #print('~',csub,test[7]) for ss,g in test.items(): if int(100*sub/n+.5)==g: sol.add(ss) #print(g,csub,testing) print(len(sol)) ```
instruction
0
87,602
11
175,204
Yes
output
1
87,602
11
175,205
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` from collections import deque n, k = map(int, input().split()) a = list(enumerate(map(int, input().split()))) orig = a for i in range(len(a)): a[i] = (a[i][1], a[i][0]) a = deque(a) testing = [] completed = 0 interesting = set() def load(): global a global testing while a and len(testing) < k: testing.append(a.popleft()) def work(): global testing global completed old = len(testing) testing = [(x[0] - 1, x[1]) for x in testing if x[0] > 1] new = len(testing) completed += (old - new) def status(): global completed global n return ((200 * completed + n) // (2 * n)) load() st = status() for remaining, i in testing: current_test = orig[i][0] - remaining + 1 if current_test == st: interesting.add(i) while a: load() work() while testing: work() print(len(interesting)) ```
instruction
0
87,603
11
175,206
Yes
output
1
87,603
11
175,207
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` import bisect n, k = map(int, input().split()) cl = list(map(int, input().split())) ncl = list(cl) def round(x): return int(x+0.5) def argsort(seq): return sorted(range(len(seq)), key=seq.__getitem__) prea = cl[:min(k, n)] for i in range(min(k, n), n): mn = min(prea) cl[i]+=mn del prea[prea.index(mn)] prea.append(cl[i]) ind = argsort(cl) pl = sorted(cl) count = 0 for i in range(n): a = pl[i] - ncl[ind[i]] pos = bisect.bisect_left(pl[: i+1], a) r = round(pos*100/n) prea = 1 for j in range(pos, i+1): if prea<r<=pl[j]-a: count+=1 break prea = pl[j]-a r = round((j+1)*100/n) print(count) ```
instruction
0
87,604
11
175,208
Yes
output
1
87,604
11
175,209
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` import heapq def solve(k, tests): percentage = 100 / len(tests) heap = [] result = 0 ans = 0 interesting = set() for s, test_time in enumerate(tests[:k]): heapq.heappush(heap, (test_time, 0, test_time, s)) i = k while len(heap) > 0: time, start, test_time, s = heapq.heappop(heap) result = round(result + percentage) if i < len(tests): heapq.heappush(heap, (time + tests[i], time, tests[i], i)) i += 1 if len(heap) > 0: end = heap[0][0] for _time, _start, _test_time, j in heap: test_start = time - _start + 1 test_end = end - _start + 1 if test_start <= result and test_end >= result and j not in interesting: interesting.add(j) ans += 1 return ans if __name__ == '__main__': n, k = [int(d) for d in input().split()] tests = [int(d) for d in input().split()] print(solve(k, tests)) ```
instruction
0
87,605
11
175,210
No
output
1
87,605
11
175,211
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` n, k = map(int, input().split()) a = list(map(int, input().split())) processes = [0] * k start = [None] * n finish = [None] * n for i in range(n): first_free = min(enumerate(processes), key=lambda x: x[1])[0] start[i] = processes[first_free] finish[i] = processes[first_free] + a[i] processes[first_free] = finish[i] finish.sort() finished = [0] * n * 151 j = 0 for i in range(n * 151): finished[i] = finished[i - 1] while finish[j] <= i and j < n - 1: if finish[j] == i: finished[i] += 1 j += 1 res = 0 for i in range(n): is_good = False for j in range(a[i]): time = start[i] + j m = finished[time] if j + 1 == round(100 * (m / n)): res += 1 break print(res) ```
instruction
0
87,606
11
175,212
No
output
1
87,606
11
175,213
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` #!/usr/bin/pypy # -*- coding: utf-8 -*- INF = float('inf') def main(): n, k = map(int, input().split()) nums = list(map(int, input().split())) mp = [0] * k ms = [0] * k ml = [0] * k task_idx = 0 for i in range(min(n, k)): mp[i] = nums[i] ml[i] = 0 task_idx += 1 comp = 0 ans = 0 pnt = -1 nt = -1 while comp < n: nst = float('inf') for j in range(k): if mp[j] > 0: nst = min(nst, mp[j] + ms[j]) for j in range(k): if mp[j] + ms[j] == nst: if ml[j] == 1 and nst - ms[j] >= pnt and pnt != 0: ans += 1 comp += 1 mp[j] = ms[j] = 0 ml[j] = 0 nt = round(float(comp) / n * 100) for i in range(k): if mp[i] != 0: if ml[i] == 1 and nst - ms[i] >= pnt and pnt != 0: ans += 1 ml[i] = 2 if nst - ms[i] < nt and ml[i] != 2: ml[i] = 1 elif mp[i] == 0 and task_idx < n: mp[i] = nums[task_idx] ms[i] = nst ml[i] = 1 task_idx += 1 pnt = nt print(ans) if __name__ == '__main__': main() ```
instruction
0
87,607
11
175,214
No
output
1
87,607
11
175,215
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to n. There are k testing processes which test solutions simultaneously. Each of them can test at most one solution at a time. At any time moment t when some testing process is not judging any solution, it takes the first solution from the queue and tests it on each test in increasing order of the test ids. Let this solution have id i, then it is being tested on the first test from time moment t till time moment t + 1, then on the second test till time moment t + 2 and so on. This solution is fully tested at time moment t + a_i, and after that the testing process immediately starts testing another solution. Consider some time moment, let there be exactly m fully tested solutions by this moment. There is a caption "System testing: d%" on the page with solutions, where d is calculated as $$$d = round\left(100⋅m/n\right),$$$ where round(x) = ⌊{x + 0.5}⌋ is a function which maps every real to the nearest integer. Vasya calls a submission interesting if there is a time moment (possibly, non-integer) when the solution is being tested on some test q, and the caption says "System testing: q%". Find the number of interesting solutions. Please note that in case when multiple processes attempt to take the first submission from the queue at the same moment (for instance, at the initial moment), the order they take the solutions does not matter. Input The first line contains two positive integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ 100) standing for the number of submissions and the number of testing processes respectively. The second line contains n positive integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 150), where a_i is equal to the number of tests the i-th submission is to be run on. Output Output the only integer — the number of interesting submissions. Examples Input 2 2 49 100 Output 1 Input 4 2 32 100 33 1 Output 2 Input 14 5 48 19 6 9 50 20 3 42 38 43 36 21 44 6 Output 5 Note Consider the first example. At time moment 0 both solutions start testing. At time moment 49 the first solution is fully tested, so at time moment 49.5 the second solution is being tested on the test 50, and the caption says "System testing: 50%" (because there is one fully tested solution out of two). So, the second solution is interesting. Consider the second example. At time moment 0 the first and the second solutions start testing. At time moment 32 the first solution is fully tested, the third solution starts testing, the caption says "System testing: 25%". At time moment 32 + 24.5 = 56.5 the third solutions is being tested on test 25, the caption is still the same, thus this solution is interesting. After that the third solution is fully tested at time moment 32 + 33 = 65, the fourth solution is fully tested at time moment 65 + 1 = 66. The captions becomes "System testing: 75%", and at time moment 74.5 the second solution is being tested on test 75. So, this solution is also interesting. Overall, there are two interesting solutions. Submitted Solution: ``` import math x = input().split() n, k = int(x[0]), int(x[1]) tmp = input().split() ais = [] for i in tmp: ais.append(int(i)) testing = [] for i in range(n): testing.append(0) m = 0 ans = set() def int_count(num, avg): for i in range(len(num)): if num[i] == 0: return ans if num[i] == avg and num[i] != 0: ans.add(i) completed = 0 res = 0 while completed < n: tmpk = k tmp_ind = 0 tmp_completed = 0 while tmpk > 0 and tmp_ind < n: if testing[tmp_ind] + 1 == ais[tmp_ind]: tmp_completed += 1 if testing[tmp_ind] < ais[tmp_ind]: testing[tmp_ind] += 1 tmpk -= 1 tmp_ind += 1 int_count(testing, math.floor((100*(completed) /n) + 0.5)) # int_count(testing, math.floor((100 * (completed) / n) + 0.5)) completed += tmp_completed print(len(ans)) ```
instruction
0
87,608
11
175,216
No
output
1
87,608
11
175,217
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Jafar has n cans of cola. Each can is described by two integers: remaining volume of cola ai and can's capacity bi (ai ≤ bi). Jafar has decided to pour all remaining cola into just 2 cans, determine if he can do this or not! Input The first line of the input contains one integer n (2 ≤ n ≤ 100 000) — number of cola cans. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 109) — volume of remaining cola in cans. The third line contains n space-separated integers that b1, b2, ..., bn (ai ≤ bi ≤ 109) — capacities of the cans. Output Print "YES" (without quotes) if it is possible to pour all remaining cola in 2 cans. Otherwise print "NO" (without quotes). You can print each letter in any case (upper or lower). Examples Input 2 3 5 3 6 Output YES Input 3 6 8 9 6 10 12 Output NO Input 5 0 0 5 0 0 1 1 8 10 5 Output YES Input 4 4 1 0 3 5 2 2 3 Output YES Note In the first sample, there are already 2 cans, so the answer is "YES". Submitted Solution: ``` def main(): input() print(("NO", "YES")[sum(map(int, input().split())) <= sum(sorted(map(int, input().split()), reverse=True)[:2])]) if __name__ == '__main__': main() ```
instruction
0
88,076
11
176,152
Yes
output
1
88,076
11
176,153
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Jafar has n cans of cola. Each can is described by two integers: remaining volume of cola ai and can's capacity bi (ai ≤ bi). Jafar has decided to pour all remaining cola into just 2 cans, determine if he can do this or not! Input The first line of the input contains one integer n (2 ≤ n ≤ 100 000) — number of cola cans. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 109) — volume of remaining cola in cans. The third line contains n space-separated integers that b1, b2, ..., bn (ai ≤ bi ≤ 109) — capacities of the cans. Output Print "YES" (without quotes) if it is possible to pour all remaining cola in 2 cans. Otherwise print "NO" (without quotes). You can print each letter in any case (upper or lower). Examples Input 2 3 5 3 6 Output YES Input 3 6 8 9 6 10 12 Output NO Input 5 0 0 5 0 0 1 1 8 10 5 Output YES Input 4 4 1 0 3 5 2 2 3 Output YES Note In the first sample, there are already 2 cans, so the answer is "YES". Submitted Solution: ``` input() list1=[*map(int,input().split())] list2=[*map(int,input().split())] sum=0 for a in list1: sum+=a print(sum) m2=0 m=0 for a in list2: if a>=m: m,m2=a,m elif a<=m and a>m2: m2=a print(m,m2) if sum<=m+m2: print('YES') else: print('NO') ```
instruction
0
88,080
11
176,160
No
output
1
88,080
11
176,161
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Jafar has n cans of cola. Each can is described by two integers: remaining volume of cola ai and can's capacity bi (ai ≤ bi). Jafar has decided to pour all remaining cola into just 2 cans, determine if he can do this or not! Input The first line of the input contains one integer n (2 ≤ n ≤ 100 000) — number of cola cans. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 109) — volume of remaining cola in cans. The third line contains n space-separated integers that b1, b2, ..., bn (ai ≤ bi ≤ 109) — capacities of the cans. Output Print "YES" (without quotes) if it is possible to pour all remaining cola in 2 cans. Otherwise print "NO" (without quotes). You can print each letter in any case (upper or lower). Examples Input 2 3 5 3 6 Output YES Input 3 6 8 9 6 10 12 Output NO Input 5 0 0 5 0 0 1 1 8 10 5 Output YES Input 4 4 1 0 3 5 2 2 3 Output YES Note In the first sample, there are already 2 cans, so the answer is "YES". Submitted Solution: ``` n=int(input()) def solve(): a=[int(i) for i in input().split()] b=[int(i) for i in input().split()] v=max(b) b.remove(v) v+=max(b) if sum(a) >=v: print('yes') else: print('no') solve() ```
instruction
0
88,082
11
176,164
No
output
1
88,082
11
176,165
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the maximum possible difference in the number of balls received. Examples Input 3 2 Output 1 Input 3 1 Output 0 Input 8 5 Output 3 Submitted Solution: ``` N,K = map(int,input().split(" ")) if(K==1): print(0) else: print(N-K) ```
instruction
0
88,185
11
176,370
Yes
output
1
88,185
11
176,371
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the maximum possible difference in the number of balls received. Examples Input 3 2 Output 1 Input 3 1 Output 0 Input 8 5 Output 3 Submitted Solution: ``` n, k = map(int, input().split()) print(n-(k-1) - n // k) ```
instruction
0
88,186
11
176,372
Yes
output
1
88,186
11
176,373
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the maximum possible difference in the number of balls received. Examples Input 3 2 Output 1 Input 3 1 Output 0 Input 8 5 Output 3 Submitted Solution: ``` n, k = list(map(int, input().split())) if k != 1: print(n-k) else: print(0) ```
instruction
0
88,187
11
176,374
Yes
output
1
88,187
11
176,375
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the maximum possible difference in the number of balls received. Examples Input 3 2 Output 1 Input 3 1 Output 0 Input 8 5 Output 3 Submitted Solution: ``` N,K = map(int,input().split()) if K < 2: print(0) else: print(N-K) ```
instruction
0
88,188
11
176,376
Yes
output
1
88,188
11
176,377
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the maximum possible difference in the number of balls received. Examples Input 3 2 Output 1 Input 3 1 Output 0 Input 8 5 Output 3 Submitted Solution: ``` N,K=map(int,input().split()) print(N-K if K!=0 else 0) ```
instruction
0
88,190
11
176,380
No
output
1
88,190
11
176,381
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the maximum possible difference in the number of balls received. Examples Input 3 2 Output 1 Input 3 1 Output 0 Input 8 5 Output 3 Submitted Solution: ``` n,k = map(int, input().split()) if k == 1: print(1) else: print(n -k) ```
instruction
0
88,191
11
176,382
No
output
1
88,191
11
176,383
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the maximum possible difference in the number of balls received. Examples Input 3 2 Output 1 Input 3 1 Output 0 Input 8 5 Output 3 Submitted Solution: ``` import sys input = sys.stdin.readline def main(): N, K = map(int, input().split()) print(N-K) if __name__ == '__main__': main() ```
instruction
0
88,192
11
176,384
No
output
1
88,192
11
176,385
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The input is given from Standard Input in the following format: > $N \ Q$ $a_1 \ b_1$ $a_2 \ b_2$ $ : \ : $ $a_Q \ b_Q$ Output * You have to print $N$ lines. * The $i$-th line should contain the number of dishes of sushi had eaten for customer $i (1 \le i \le N)$. Constraints * $3 \le N, Q \le 100,000$ * $1 \le a_i \le N$ * $1 \le b_i \le 10^{12}$ * Any final results do not exceed $2 \times 10^{13}$. Subtasks Subtask 1 [ $60$ points ] * $N, Q \le 100$ * $b_i = 1$ Subtask 2 [ $400$ points ] * $N, Q \le 100$ * $b_i \le 10^{12}$ Subtask 3 [ $240$ points ] * $N, Q \le 100,000$ * $b_i = 1$ Subtask 4 [ $500$ points ] * There are no additional constraints. Output * You have to print $N$ lines. * The $i$-th line should contain the number of dishes of sushi had eaten for customer $i (1 \le i \le N)$. Constraints * $3 \le N, Q \le 100,000$ * $1 \le a_i \le N$ * $1 \le b_i \le 10^{12}$ * Any final results do not exceed $2 \times 10^{13}$. Subtasks Subtask 1 [ $60$ points ] * $N, Q \le 100$ * $b_i = 1$ Subtask 2 [ $400$ points ] * $N, Q \le 100$ * $b_i \le 10^{12}$ Subtask 3 [ $240$ points ] * $N, Q \le 100,000$ * $b_i = 1$ Subtask 4 [ $500$ points ] * There are no additional constraints. Input The input is given from Standard Input in the following format: > $N \ Q$ $a_1 \ b_1$ $a_2 \ b_2$ $ : \ : $ $a_Q \ b_Q$ Examples Input 9 3 5 11 8 4 4 7 Output 4 4 4 4 2 2 1 1 0 Input 6 6 3 5 6 11 1 6 4 7 5 2 2 5 Output 10 10 5 5 4 2 Input 5 6 1 1 2 1 3 1 1 1 5 1 3 1 Output 2 2 1 1 0 Input 10 10 10 10 9 20 8 30 7 40 6 50 5 60 4 70 3 80 2 90 1 100 Output 223 123 77 50 33 21 12 7 3 1 Submitted Solution: ``` import sys import numpy as np import numba from numba import njit i8 = numba.int64 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @njit((i8[:], ), cache=True) def build(raw_data): bit = raw_data.copy() for i in range(len(bit)): j = i + (i & (-i)) if j < len(bit): bit[j] += bit[i] return bit @njit((i8[:], i8), cache=True) def get_sum(bit, i): s = 0 while i: s += bit[i] i -= i & -i return s @njit((i8[:], i8, i8), cache=True) def add(bit, i, x): while i < len(bit): bit[i] += x i += i & -i @njit((i8[:], i8), cache=True) def find_kth_element(bit, k): N = len(bit) x, sx = 0, 0 dx = 1 while 2 * dx < N: dx *= 2 while dx: y = x + dx if y < N: sy = sx + bit[y] if sy < k: x, sx = y, sy dx //= 2 return x + 1 @njit((i8, i8[:]), cache=True) def main(N, AB): A, B = AB[::2], AB[1::2] Q = len(A) bit = np.zeros(N + 1, np.int64) # 長方形の右上になる x 座標集合を管理 bit_raw = np.zeros(N + 1, np.int64) H = np.zeros(N + 1, np.int64) # 長方形の高さを管理 H[0] = 10**13 + 10 bit_raw[N] = 1 add(bit, N, 1) for i in range(Q): a, b = A[i], B[i] n = get_sum(bit, a - 1) h = H[find_kth_element(bit, 1 + n)] if not bit_raw[a]: bit_raw[a] = 1 add(bit, a, 1) H[a] = h r = a while b: l = 0 if n == 0 else find_kth_element(bit, n) n -= 1 area = (H[l] - H[r]) * (r - l) if area <= b: b -= area if l: bit_raw[l] = 0 add(bit, l, -1) H[l], H[r] = 0, H[l] continue k = b // (r - l) b -= k * (r - l) H[r] += k if b: m = l + b bit_raw[m] = 1 add(bit, m, 1) H[m] = H[r] + 1 b = 0 for n in range(N, 0, -1): H[n - 1] = max(H[n - 1], H[n]) return H[1:N + 1] N, Q = map(int, readline().split()) AB = np.array(read().split(), np.int64) ans = main(N, AB) print('\n'.join(map(str, ans.tolist()))) ```
instruction
0
88,262
11
176,524
No
output
1
88,262
11
176,525
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the Catowice city next weekend the cat contest will be held. However, the jury members and the contestants haven't been selected yet. There are n residents and n cats in the Catowice, and each resident has exactly one cat living in his house. The residents and cats are numbered with integers from 1 to n, where the i-th cat is living in the house of i-th resident. Each Catowice resident is in friendship with several cats, including the one living in his house. In order to conduct a contest, at least one jury member is needed and at least one cat contestant is needed. Of course, every jury member should know none of the contestants. For the contest to be successful, it's also needed that the number of jury members plus the number of contestants is equal to n. Please help Catowice residents to select the jury and the contestants for the upcoming competition, or determine that it's impossible to do. Input The first line contains an integer t (1 ≤ t ≤ 100 000), the number of test cases. Then description of t test cases follow, where each description is as follows: The first line contains integers n and m (1 ≤ n ≤ m ≤ 10^6), the number of Catowice residents and the number of friendship pairs between residents and cats. Each of the next m lines contains integers a_i and b_i (1 ≤ a_i, b_i ≤ n), denoting that a_i-th resident is acquaintances with b_i-th cat. It's guaranteed that each pair of some resident and some cat is listed at most once. It's guaranteed, that for every i there exists a pair between i-th resident and i-th cat. Different test cases are separated with an empty line. It's guaranteed, that the sum of n over all test cases is at most 10^6 and that the sum of m over all test cases is at most 10^6. Output For every test case print: * "No", if it's impossible to select the jury and contestants. * Otherwise print "Yes". In the second line print two integers j and p (1 ≤ j, 1 ≤ p, j + p = n) — the number of jury members and the number of contest participants. In the third line print j distinct integers from 1 to n, the indices of the residents forming a jury. In the fourth line print p distinct integers from 1 to n, the indices of the cats, which will participate in the contest. In case there are several correct answers, print any of them. Example Input 4 3 4 1 1 2 2 3 3 1 3 3 7 1 1 1 2 1 3 2 2 3 1 3 2 3 3 1 1 1 1 2 4 1 1 1 2 2 1 2 2 Output Yes 2 1 1 3 2 Yes 1 2 2 1 3 No No Note In the first test case, we can select the first and the third resident as a jury. Both of them are not acquaintances with a second cat, so we can select it as a contestant. In the second test case, we can select the second resident as a jury. He is not an acquaintances with a first and a third cat, so they can be selected as contestants. In the third test case, the only resident is acquaintances with the only cat, so they can't be in the contest together. So it's not possible to make a contest with at least one jury and at least one cat. In the fourth test case, each resident is acquaintances with every cat, so it's again not possible to make a contest with at least one jury and at least one cat. Submitted Solution: ``` import sys def dfs1(v): used[v] = True for u in graph[v]: if not used[u]: dfs1(u) order.append(v) def dfs2(v, c): comp[v] = c for u in transparent_graph[v]: if comp[u] is None: dfs2(u, c) """ fin = open("fin.txt", "r") fout = open("fout.txt", "w") """ fin = sys.stdin fout = sys.stdout t = int(fin.readline()) for test in range(t): n, m = map(int, fin.readline().split()) graph = [list() for i in range(n)] transparent_graph = [list() for i in range(n)] for i in range(m): w, c = map(int, fin.readline().split()) w -= 1 c -= 1 # !w or !c # it means that w => !c # or c => !w graph[w].append(c) transparent_graph[c].append(w) order = list() used = [False] * n for i in range(n): if not used[i]: dfs1(i) order.reverse() comp = [None] * n c = 1 for v in order: if comp[v] is None: dfs2(v, c) c += 1 if c == 2: print("No", file=fout) fin.readline() continue villagers = list() cats = list() for i in range(n): if comp[i] == 1: villagers.append(i + 1) else: cats.append(i + 1) if len(villagers) == 0 or len(cats) == 0: print("No", file=fout) fin.readline() continue print("Yes", file=fout) print(len(villagers), len(cats), file=fout) for i in villagers: print(i, end=" ", file=fout) print(file=fout) for i in cats: print(i, end=" ", file=fout) print(file=fout) fin.readline() ```
instruction
0
88,479
11
176,958
No
output
1
88,479
11
176,959
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the Catowice city next weekend the cat contest will be held. However, the jury members and the contestants haven't been selected yet. There are n residents and n cats in the Catowice, and each resident has exactly one cat living in his house. The residents and cats are numbered with integers from 1 to n, where the i-th cat is living in the house of i-th resident. Each Catowice resident is in friendship with several cats, including the one living in his house. In order to conduct a contest, at least one jury member is needed and at least one cat contestant is needed. Of course, every jury member should know none of the contestants. For the contest to be successful, it's also needed that the number of jury members plus the number of contestants is equal to n. Please help Catowice residents to select the jury and the contestants for the upcoming competition, or determine that it's impossible to do. Input The first line contains an integer t (1 ≤ t ≤ 100 000), the number of test cases. Then description of t test cases follow, where each description is as follows: The first line contains integers n and m (1 ≤ n ≤ m ≤ 10^6), the number of Catowice residents and the number of friendship pairs between residents and cats. Each of the next m lines contains integers a_i and b_i (1 ≤ a_i, b_i ≤ n), denoting that a_i-th resident is acquaintances with b_i-th cat. It's guaranteed that each pair of some resident and some cat is listed at most once. It's guaranteed, that for every i there exists a pair between i-th resident and i-th cat. Different test cases are separated with an empty line. It's guaranteed, that the sum of n over all test cases is at most 10^6 and that the sum of m over all test cases is at most 10^6. Output For every test case print: * "No", if it's impossible to select the jury and contestants. * Otherwise print "Yes". In the second line print two integers j and p (1 ≤ j, 1 ≤ p, j + p = n) — the number of jury members and the number of contest participants. In the third line print j distinct integers from 1 to n, the indices of the residents forming a jury. In the fourth line print p distinct integers from 1 to n, the indices of the cats, which will participate in the contest. In case there are several correct answers, print any of them. Example Input 4 3 4 1 1 2 2 3 3 1 3 3 7 1 1 1 2 1 3 2 2 3 1 3 2 3 3 1 1 1 1 2 4 1 1 1 2 2 1 2 2 Output Yes 2 1 1 3 2 Yes 1 2 2 1 3 No No Note In the first test case, we can select the first and the third resident as a jury. Both of them are not acquaintances with a second cat, so we can select it as a contestant. In the second test case, we can select the second resident as a jury. He is not an acquaintances with a first and a third cat, so they can be selected as contestants. In the third test case, the only resident is acquaintances with the only cat, so they can't be in the contest together. So it's not possible to make a contest with at least one jury and at least one cat. In the fourth test case, each resident is acquaintances with every cat, so it's again not possible to make a contest with at least one jury and at least one cat. Submitted Solution: ``` print('NO') ```
instruction
0
88,480
11
176,960
No
output
1
88,480
11
176,961
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the Catowice city next weekend the cat contest will be held. However, the jury members and the contestants haven't been selected yet. There are n residents and n cats in the Catowice, and each resident has exactly one cat living in his house. The residents and cats are numbered with integers from 1 to n, where the i-th cat is living in the house of i-th resident. Each Catowice resident is in friendship with several cats, including the one living in his house. In order to conduct a contest, at least one jury member is needed and at least one cat contestant is needed. Of course, every jury member should know none of the contestants. For the contest to be successful, it's also needed that the number of jury members plus the number of contestants is equal to n. Please help Catowice residents to select the jury and the contestants for the upcoming competition, or determine that it's impossible to do. Input The first line contains an integer t (1 ≤ t ≤ 100 000), the number of test cases. Then description of t test cases follow, where each description is as follows: The first line contains integers n and m (1 ≤ n ≤ m ≤ 10^6), the number of Catowice residents and the number of friendship pairs between residents and cats. Each of the next m lines contains integers a_i and b_i (1 ≤ a_i, b_i ≤ n), denoting that a_i-th resident is acquaintances with b_i-th cat. It's guaranteed that each pair of some resident and some cat is listed at most once. It's guaranteed, that for every i there exists a pair between i-th resident and i-th cat. Different test cases are separated with an empty line. It's guaranteed, that the sum of n over all test cases is at most 10^6 and that the sum of m over all test cases is at most 10^6. Output For every test case print: * "No", if it's impossible to select the jury and contestants. * Otherwise print "Yes". In the second line print two integers j and p (1 ≤ j, 1 ≤ p, j + p = n) — the number of jury members and the number of contest participants. In the third line print j distinct integers from 1 to n, the indices of the residents forming a jury. In the fourth line print p distinct integers from 1 to n, the indices of the cats, which will participate in the contest. In case there are several correct answers, print any of them. Example Input 4 3 4 1 1 2 2 3 3 1 3 3 7 1 1 1 2 1 3 2 2 3 1 3 2 3 3 1 1 1 1 2 4 1 1 1 2 2 1 2 2 Output Yes 2 1 1 3 2 Yes 1 2 2 1 3 No No Note In the first test case, we can select the first and the third resident as a jury. Both of them are not acquaintances with a second cat, so we can select it as a contestant. In the second test case, we can select the second resident as a jury. He is not an acquaintances with a first and a third cat, so they can be selected as contestants. In the third test case, the only resident is acquaintances with the only cat, so they can't be in the contest together. So it's not possible to make a contest with at least one jury and at least one cat. In the fourth test case, each resident is acquaintances with every cat, so it's again not possible to make a contest with at least one jury and at least one cat. Submitted Solution: ``` import sys def dfs1(v): used[v] = True for u in graph[v]: if not used[u]: dfs1(u) order.append(v) def dfs2(v, c): comp[v] = c for u in transparent_graph[v]: if comp[u] is None: dfs2(u, c) """ fin = open("fin.txt", "r") fout = open("fout.txt", "w") """ fin = sys.stdin fout = sys.stdout t = int(fin.readline()) for test in range(t): n, m = map(int, fin.readline().split()) graph = [list() for i in range(n)] transparent_graph = [list() for i in range(n)] for i in range(m): w, c = map(int, fin.readline().split()) w -= 1 c -= 1 # !w or !c # it means that w => !c # or c => !w graph[w].append(c) transparent_graph[c].append(w) order = list() used = [False] * n for i in range(n): if not used[i]: dfs1(i) order.reverse() comp = [None] * n c = 1 for v in order: if comp[v] is None: dfs2(v, c) c += 1 if c == 1: print("No", file=fout) fin.readline() continue villagers = list() cats = list() for i in range(n): if comp[i] == 1: villagers.append(i + 1) else: cats.append(i + 1) if len(villagers) == 0 or len(cats) == 0: print("No", file=fout) fin.readline() continue print("Yes", file=fout) print(len(villagers), len(cats), file=fout) for i in villagers: print(i, end=" ", file=fout) print(file=fout) for i in cats: print(i, end=" ", file=fout) print(file=fout) fin.readline() ```
instruction
0
88,481
11
176,962
No
output
1
88,481
11
176,963
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the Catowice city next weekend the cat contest will be held. However, the jury members and the contestants haven't been selected yet. There are n residents and n cats in the Catowice, and each resident has exactly one cat living in his house. The residents and cats are numbered with integers from 1 to n, where the i-th cat is living in the house of i-th resident. Each Catowice resident is in friendship with several cats, including the one living in his house. In order to conduct a contest, at least one jury member is needed and at least one cat contestant is needed. Of course, every jury member should know none of the contestants. For the contest to be successful, it's also needed that the number of jury members plus the number of contestants is equal to n. Please help Catowice residents to select the jury and the contestants for the upcoming competition, or determine that it's impossible to do. Input The first line contains an integer t (1 ≤ t ≤ 100 000), the number of test cases. Then description of t test cases follow, where each description is as follows: The first line contains integers n and m (1 ≤ n ≤ m ≤ 10^6), the number of Catowice residents and the number of friendship pairs between residents and cats. Each of the next m lines contains integers a_i and b_i (1 ≤ a_i, b_i ≤ n), denoting that a_i-th resident is acquaintances with b_i-th cat. It's guaranteed that each pair of some resident and some cat is listed at most once. It's guaranteed, that for every i there exists a pair between i-th resident and i-th cat. Different test cases are separated with an empty line. It's guaranteed, that the sum of n over all test cases is at most 10^6 and that the sum of m over all test cases is at most 10^6. Output For every test case print: * "No", if it's impossible to select the jury and contestants. * Otherwise print "Yes". In the second line print two integers j and p (1 ≤ j, 1 ≤ p, j + p = n) — the number of jury members and the number of contest participants. In the third line print j distinct integers from 1 to n, the indices of the residents forming a jury. In the fourth line print p distinct integers from 1 to n, the indices of the cats, which will participate in the contest. In case there are several correct answers, print any of them. Example Input 4 3 4 1 1 2 2 3 3 1 3 3 7 1 1 1 2 1 3 2 2 3 1 3 2 3 3 1 1 1 1 2 4 1 1 1 2 2 1 2 2 Output Yes 2 1 1 3 2 Yes 1 2 2 1 3 No No Note In the first test case, we can select the first and the third resident as a jury. Both of them are not acquaintances with a second cat, so we can select it as a contestant. In the second test case, we can select the second resident as a jury. He is not an acquaintances with a first and a third cat, so they can be selected as contestants. In the third test case, the only resident is acquaintances with the only cat, so they can't be in the contest together. So it's not possible to make a contest with at least one jury and at least one cat. In the fourth test case, each resident is acquaintances with every cat, so it's again not possible to make a contest with at least one jury and at least one cat. Submitted Solution: ``` from collections import deque t=int(input()) def bfs(): global check,ans ans=0 d=deque() check=[0]*(n+1) d.append(1) while(len(d)>0): for i in range(len(v[d[0]])): if check[v[d[0]][i]]==0: check[v[d[0]][i]]=1 ans+=1 d.append(v[d[0]][i]) d.pop() def bfs2(): global check2, ans2 ans2= 0 d=deque() check2=[0]*(n+1) d.append(1) while (len(d) > 0): for i in range(len(v2[d[0]])): if check2[v2[d[0]][i]]==0: check2[v2[d[0]][i]]=1 ans2+= 1 d.append(v2[d[0]][i]) d.pop() for i2 in range(t): n,m=map(int,input().split()) v=[[]for i in range(n+1)] v2=[[]for i in range(n+1)] for i in range(m): a,b=map(int,input().split()) v[a].append(b) v2[b].append(a) bfs() bfs2() if i2<t-1: s=str(input()) if 0<ans<n: print("YES") print(ans,n-ans) for i in range(1,n+1): if check[i]==1: print(i,end=" ") print("") for i in range(1,n+1): if check[i]==0: print(i,end=" ") print("") elif 0<ans2<n: print("YES") print(n-ans2,ans2) for i in range(1, n + 1): if check2[i] == 0: print(i, end=" ") print("") for i in range(1, n + 1): if check2[i] == 1: print(i, end=" ") print("") else: print("NO") ```
instruction
0
88,482
11
176,964
No
output
1
88,482
11
176,965
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented her an integer array a. Several hours after starting her journey home Nastya remembered about the present. To entertain herself she decided to check, are there four different indices x, y, z, w such that a_x + a_y = a_z + a_w. Her train has already arrived the destination, but she still hasn't found the answer. Can you help her unravel the mystery? Input The first line contains the single integer n (4 ≤ n ≤ 200 000) — the size of the array. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2.5 ⋅ 10^6). Output Print "YES" if there are such four indices, and "NO" otherwise. If such indices exist, print these indices x, y, z and w (1 ≤ x, y, z, w ≤ n). If there are multiple answers, print any of them. Examples Input 6 2 1 5 2 7 4 Output YES 2 3 1 6 Input 5 1 3 1 9 20 Output NO Note In the first example a_2 + a_3 = 1 + 5 = 2 + 4 = a_1 + a_6. Note that there are other answer, for example, 2 3 4 6. In the second example, we can't choose four indices. The answer 1 2 2 3 is wrong, because indices should be different, despite that a_1 + a_2 = 1 + 3 = 3 + 1 = a_2 + a_3 Submitted Solution: ``` from sys import stdin input=stdin.readline def A707(): from collections import defaultdict CAP = 2500001 n=int(input()) a=list(map(int,input().split())) d=[0]*(CAP*2) i=n-2 j=n-1 found=False while i >= 0: j = i + 1 while j < n: if d[a[i]+a[j]] != 0: ID = i*n + j for k in d[a[i]+a[j]]: if not (k % n == i or k % n == j or k//n == i or k//n == j): print('YES') print(i+1,j+1,k%n+1,k//n+1) found=True break d[a[i]+a[j]].append(ID) else: d[a[i]+a[j]] = [i*n+j] j += 1 if found: break i -= 1 if found: break if not found: print('NO') A707() ```
instruction
0
88,647
11
177,294
Yes
output
1
88,647
11
177,295
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented her an integer array a. Several hours after starting her journey home Nastya remembered about the present. To entertain herself she decided to check, are there four different indices x, y, z, w such that a_x + a_y = a_z + a_w. Her train has already arrived the destination, but she still hasn't found the answer. Can you help her unravel the mystery? Input The first line contains the single integer n (4 ≤ n ≤ 200 000) — the size of the array. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2.5 ⋅ 10^6). Output Print "YES" if there are such four indices, and "NO" otherwise. If such indices exist, print these indices x, y, z and w (1 ≤ x, y, z, w ≤ n). If there are multiple answers, print any of them. Examples Input 6 2 1 5 2 7 4 Output YES 2 3 1 6 Input 5 1 3 1 9 20 Output NO Note In the first example a_2 + a_3 = 1 + 5 = 2 + 4 = a_1 + a_6. Note that there are other answer, for example, 2 3 4 6. In the second example, we can't choose four indices. The answer 1 2 2 3 is wrong, because indices should be different, despite that a_1 + a_2 = 1 + 3 = 3 + 1 = a_2 + a_3 Submitted Solution: ``` n = int(input()) arr = list(map(int, input().split())) d = {} flag = True for i1 in range(n): for j1 in range(i1): if arr[i1]+arr[j1] in d: i2, j2 = d[arr[i1]+arr[j1]] if len(set([i1, i2, j1, j2]))==4: print("YES") print(j2+1, i2+1, j1+1, i1+1) flag = False break else: d[arr[i1]+arr[j1]] = (i1, j1) if flag==False: break if flag: print("NO") ```
instruction
0
88,648
11
177,296
Yes
output
1
88,648
11
177,297
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented her an integer array a. Several hours after starting her journey home Nastya remembered about the present. To entertain herself she decided to check, are there four different indices x, y, z, w such that a_x + a_y = a_z + a_w. Her train has already arrived the destination, but she still hasn't found the answer. Can you help her unravel the mystery? Input The first line contains the single integer n (4 ≤ n ≤ 200 000) — the size of the array. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2.5 ⋅ 10^6). Output Print "YES" if there are such four indices, and "NO" otherwise. If such indices exist, print these indices x, y, z and w (1 ≤ x, y, z, w ≤ n). If there are multiple answers, print any of them. Examples Input 6 2 1 5 2 7 4 Output YES 2 3 1 6 Input 5 1 3 1 9 20 Output NO Note In the first example a_2 + a_3 = 1 + 5 = 2 + 4 = a_1 + a_6. Note that there are other answer, for example, 2 3 4 6. In the second example, we can't choose four indices. The answer 1 2 2 3 is wrong, because indices should be different, despite that a_1 + a_2 = 1 + 3 = 3 + 1 = a_2 + a_3 Submitted Solution: ``` from collections import Counter n=int(input()) m=[int(j) for j in input().split()] m=m new={} res=[] for i in range(len(m)): for j in range(i+1, len(m)): if m[i]+m[j] in new: if i not in new[m[i]+m[j]] and j not in new[m[i]+m[j]]: z=new[m[i]+m[j]][0] x=new[m[i]+m[j]][1] res.extend([i, j, z, x]) break else: continue else: new[m[i]+m[j]]=[i, j] else: continue break if res: print("YES") print(" ".join([str(e+1) for e in res])) else: print("NO") ```
instruction
0
88,650
11
177,300
Yes
output
1
88,650
11
177,301
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented her an integer array a. Several hours after starting her journey home Nastya remembered about the present. To entertain herself she decided to check, are there four different indices x, y, z, w such that a_x + a_y = a_z + a_w. Her train has already arrived the destination, but she still hasn't found the answer. Can you help her unravel the mystery? Input The first line contains the single integer n (4 ≤ n ≤ 200 000) — the size of the array. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2.5 ⋅ 10^6). Output Print "YES" if there are such four indices, and "NO" otherwise. If such indices exist, print these indices x, y, z and w (1 ≤ x, y, z, w ≤ n). If there are multiple answers, print any of them. Examples Input 6 2 1 5 2 7 4 Output YES 2 3 1 6 Input 5 1 3 1 9 20 Output NO Note In the first example a_2 + a_3 = 1 + 5 = 2 + 4 = a_1 + a_6. Note that there are other answer, for example, 2 3 4 6. In the second example, we can't choose four indices. The answer 1 2 2 3 is wrong, because indices should be different, despite that a_1 + a_2 = 1 + 3 = 3 + 1 = a_2 + a_3 Submitted Solution: ``` import sys input = sys.stdin.readline ############ ---- Input Functions ---- ############ def inp(): return(int(input())) def inlt(): return(list(map(int,input().split()))) def insr(): s = input() return(list(s[:len(s) - 1])) def invr(): return(map(int,input().split())) n = inp() a = inlt() sums = dict() # With 8 numbers we must have a pair. Try all 8^4 combinations. def find_ans(p): n = len(p) for i in range(n): for j in range(i+1,n): for k in range(j+1,n): for l in range(k+1,n): if a[i]+a[j] == a[k] + a[l]: print(f"{i+1} {j+1} {k+1} {l+1}") exit() for i in range(n): for j in range(i+1,n): s = a[i]+a[j] if s in sums: pairs = sums[s] for k in range(len(pairs) // 2): pair = (pairs[2*k], pairs[2*k+1]) if i not in pair and j not in pair: print("YES") print(f"{i+1} {j+1} {pair[0]+1} {pair[1]+1}") exit() sums[s] = sums[s] + (i,j) if len(sums[s]) >= 8: find_ans(sums[s]) else: sums[s] = (i,j) print("NO") ```
instruction
0
88,651
11
177,302
No
output
1
88,651
11
177,303
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented her an integer array a. Several hours after starting her journey home Nastya remembered about the present. To entertain herself she decided to check, are there four different indices x, y, z, w such that a_x + a_y = a_z + a_w. Her train has already arrived the destination, but she still hasn't found the answer. Can you help her unravel the mystery? Input The first line contains the single integer n (4 ≤ n ≤ 200 000) — the size of the array. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2.5 ⋅ 10^6). Output Print "YES" if there are such four indices, and "NO" otherwise. If such indices exist, print these indices x, y, z and w (1 ≤ x, y, z, w ≤ n). If there are multiple answers, print any of them. Examples Input 6 2 1 5 2 7 4 Output YES 2 3 1 6 Input 5 1 3 1 9 20 Output NO Note In the first example a_2 + a_3 = 1 + 5 = 2 + 4 = a_1 + a_6. Note that there are other answer, for example, 2 3 4 6. In the second example, we can't choose four indices. The answer 1 2 2 3 is wrong, because indices should be different, despite that a_1 + a_2 = 1 + 3 = 3 + 1 = a_2 + a_3 Submitted Solution: ``` n = int(input()) l = [int(i) for i in input().split(' ')] m = {} for i in range(0,n-1): for j in range(i+1, n): sm = l[i]+l[j] if sm in m: k,l = m[sm] print(k,l) if (k != i and k != j) and (l != i and l != j): print("YES") print(i+1,j+1,k+1,l+1) quit() else: m[sm] = [i,j] print("NO") ```
instruction
0
88,653
11
177,306
No
output
1
88,653
11
177,307
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented her an integer array a. Several hours after starting her journey home Nastya remembered about the present. To entertain herself she decided to check, are there four different indices x, y, z, w such that a_x + a_y = a_z + a_w. Her train has already arrived the destination, but she still hasn't found the answer. Can you help her unravel the mystery? Input The first line contains the single integer n (4 ≤ n ≤ 200 000) — the size of the array. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2.5 ⋅ 10^6). Output Print "YES" if there are such four indices, and "NO" otherwise. If such indices exist, print these indices x, y, z and w (1 ≤ x, y, z, w ≤ n). If there are multiple answers, print any of them. Examples Input 6 2 1 5 2 7 4 Output YES 2 3 1 6 Input 5 1 3 1 9 20 Output NO Note In the first example a_2 + a_3 = 1 + 5 = 2 + 4 = a_1 + a_6. Note that there are other answer, for example, 2 3 4 6. In the second example, we can't choose four indices. The answer 1 2 2 3 is wrong, because indices should be different, despite that a_1 + a_2 = 1 + 3 = 3 + 1 = a_2 + a_3 Submitted Solution: ``` n = int(input()) n_array = list(map(int, input().split())) for x_index in range(n-3): for y_index in range(x_index+1, n-2): for z_index in range(y_index+1, n-1): for w_index in range(z_index+1, n): if (n_array[x_index] + n_array[y_index] == n_array[z_index] + n_array[w_index]): print(x_index+1, y_index+1, z_index+1, w_index+1, sep = " ") exit() elif (n_array[x_index] + n_array[z_index] == n_array[y_index] + n_array[w_index]): print(x_index+1, z_index+1, y_index+1, w_index+1, sep = " ") exit() elif (n_array[x_index] + n_array[w_index] == n_array[z_index] + n_array[y_index]): print(x_index+1, w_index+1, z_index+1, y_index+1, sep = " ") exit() print("NO") ```
instruction
0
88,654
11
177,308
No
output
1
88,654
11
177,309
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments. Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. Input The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively. The second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument. Output In the first line output one integer m representing the maximum number of instruments Amr can learn. In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order. if there are multiple optimal solutions output any. It is not necessary to use all days for studying. Examples Input 4 10 4 3 1 2 Output 4 1 2 3 4 Input 5 6 4 3 1 1 2 Output 3 1 3 4 Input 1 3 4 Output 0 Note In the first test Amr can learn all 4 instruments. In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. In the third test Amr doesn't have enough time to learn the only presented instrument. Submitted Solution: ``` n,k=map(int,input().split()) l=list(map(int,input().split())) new=[] ans=[] s=0 for i in range(n): new.append([l[i],i+1]) new.sort() for i in range(n): s+=new[i][0] if(s<=k): ans.append(new[i][1]) else: break if(len(ans)==0): print(0) else: print(len(ans)) print(*ans) ```
instruction
0
88,825
11
177,650
Yes
output
1
88,825
11
177,651
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments. Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. Input The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively. The second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument. Output In the first line output one integer m representing the maximum number of instruments Amr can learn. In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order. if there are multiple optimal solutions output any. It is not necessary to use all days for studying. Examples Input 4 10 4 3 1 2 Output 4 1 2 3 4 Input 5 6 4 3 1 1 2 Output 3 1 3 4 Input 1 3 4 Output 0 Note In the first test Amr can learn all 4 instruments. In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. In the third test Amr doesn't have enough time to learn the only presented instrument. Submitted Solution: ``` s=list(map(int,input().split())) l=list(map(int,input().split())) s1=sorted(l) su=0 idx={} for i in range(len(l)): try: idx[l[i]].append(i) except: idx[l[i]]=[i] x=[] for i in s1: su+=i if(su<=s[1]): x.append(idx[i][0]+1) idx[i].pop(0) print(len(x)) if(len(x)!=0): print(*x,sep=" ") ```
instruction
0
88,826
11
177,652
Yes
output
1
88,826
11
177,653
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments. Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. Input The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively. The second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument. Output In the first line output one integer m representing the maximum number of instruments Amr can learn. In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order. if there are multiple optimal solutions output any. It is not necessary to use all days for studying. Examples Input 4 10 4 3 1 2 Output 4 1 2 3 4 Input 5 6 4 3 1 1 2 Output 3 1 3 4 Input 1 3 4 Output 0 Note In the first test Amr can learn all 4 instruments. In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. In the third test Amr doesn't have enough time to learn the only presented instrument. Submitted Solution: ``` x,y = list(map(int,input().split())) arr = list(map(int,input().split())) copy = list(arr) arr = sorted(arr) count, i = 0,0 res = [] while ((count<=y) & (i<x)): if (count + arr[i] <=y): res.append(copy.index(arr[i])+1) copy[copy.index(arr[i])] = -1 count += arr[i] i+=1 else: break print (i) if (i!=0): res = map(str,res) print (" ".join(res)) ```
instruction
0
88,827
11
177,654
Yes
output
1
88,827
11
177,655
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments. Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. Input The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively. The second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument. Output In the first line output one integer m representing the maximum number of instruments Amr can learn. In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order. if there are multiple optimal solutions output any. It is not necessary to use all days for studying. Examples Input 4 10 4 3 1 2 Output 4 1 2 3 4 Input 5 6 4 3 1 1 2 Output 3 1 3 4 Input 1 3 4 Output 0 Note In the first test Amr can learn all 4 instruments. In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. In the third test Amr doesn't have enough time to learn the only presented instrument. Submitted Solution: ``` n,k = map(int,input().split()) a = list(map(int,input().split())) b = a.copy();d=1 l=list([0]);vis=[0]*n sumo,cnt,j=0,0,0 a.sort() for i in range(n): if sumo+a[i]<=k: sumo+=a[i]; for j in range(n): if a[i]==b[j] and vis[j]==0: vis[j]=1;l.append(j+1);break print(len(l)-1) for i in l[1:]: print(i,end=" ") ```
instruction
0
88,828
11
177,656
Yes
output
1
88,828
11
177,657
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments. Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. Input The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively. The second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument. Output In the first line output one integer m representing the maximum number of instruments Amr can learn. In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order. if there are multiple optimal solutions output any. It is not necessary to use all days for studying. Examples Input 4 10 4 3 1 2 Output 4 1 2 3 4 Input 5 6 4 3 1 1 2 Output 3 1 3 4 Input 1 3 4 Output 0 Note In the first test Amr can learn all 4 instruments. In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. In the third test Amr doesn't have enough time to learn the only presented instrument. Submitted Solution: ``` n, k = map(int, input().split()) k_1 = list(map(int, input().split())) summ = 0 index = [] for i in range(len(k_1)): if (summ + k_1[i]) <= k: summ += k_1[i] index.append(i+1) if len(index) == 0: print(0) else: print(len(index)) for i in index: print(i, end=" ") ```
instruction
0
88,829
11
177,658
No
output
1
88,829
11
177,659
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments. Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. Input The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively. The second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument. Output In the first line output one integer m representing the maximum number of instruments Amr can learn. In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order. if there are multiple optimal solutions output any. It is not necessary to use all days for studying. Examples Input 4 10 4 3 1 2 Output 4 1 2 3 4 Input 5 6 4 3 1 1 2 Output 3 1 3 4 Input 1 3 4 Output 0 Note In the first test Amr can learn all 4 instruments. In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. In the third test Amr doesn't have enough time to learn the only presented instrument. Submitted Solution: ``` n,k=map(int,input().split(" ")) a=[int(i) for i in input().split(" ")] a=list(set(a)) z=sorted(a) i=0 while(k!=0) and i<n: if z[i]>k: print(0) break else: k=k-z[i] print(z[i],end=" ") i=i+1 ```
instruction
0
88,830
11
177,660
No
output
1
88,830
11
177,661
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea. Amr has n instruments, it takes ai days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments. Amr asked for your help to distribute his free days between instruments so that he can achieve his goal. Input The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively. The second line contains n integers ai (1 ≤ ai ≤ 100), representing number of days required to learn the i-th instrument. Output In the first line output one integer m representing the maximum number of instruments Amr can learn. In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order. if there are multiple optimal solutions output any. It is not necessary to use all days for studying. Examples Input 4 10 4 3 1 2 Output 4 1 2 3 4 Input 5 6 4 3 1 1 2 Output 3 1 3 4 Input 1 3 4 Output 0 Note In the first test Amr can learn all 4 instruments. In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}. In the third test Amr doesn't have enough time to learn the only presented instrument. Submitted Solution: ``` instr, days = (int(x) for x in input().split()) # print (instr, days) arr = [(int(y), x + 1) for x, y in enumerate(input().split())] arr.sort() if arr[0][0] > days: print(0) else: result = [] for hard in arr: days -= hard[0] if days >= 0: result.append(str(hard[1])) else: break print (" ".join(result)) ```
instruction
0
88,831
11
177,662
No
output
1
88,831
11
177,663
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≤ k ≤ 109, 0 ≤ a, b ≤ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem. Submitted Solution: ``` # http://codeforces.com/contest/765/problem/A # http://codeforces.com/contest/765/problem/B # http://codeforces.com/contest/765/problem/C def Neverending_competitions(): n = int(input()) home = input() for i in range(n): new = input() if n % 2 == 0: return "home" else: return "contest" #print(Neverending_competitions()) def Code_obfuscation(): s = input() a = [0] * 26 okay = True for i in s: for j in range(ord(i)-97): if not a[j]: okay = False break if okay: a[ord(i) - 97] = 1 else: break if okay: print("YES") else: print("NO") #Code_obfuscation() def Table_Tennis_Game_2(): n = input().split() k = int(n[0]) a = int(n[1]) b = int(n[2]) if a >= k and b>=k: return int(a/k) + int(b/k) elif a % k == 0: return int(a/k) elif b % k == 0: return int(b/k) else: return -1 print(Table_Tennis_Game_2()) ```
instruction
0
88,904
11
177,808
No
output
1
88,904
11
177,809
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. Constraints * 1≦N≦10^5 * 0≦A_i≦N-1 Input The input is given from Standard Input in the following format: N A_1 A_2 ... A_N Output Print the number of the possible orders in which they were standing, modulo 10^9+7. Examples Input 5 2 4 4 0 2 Output 4 Input 7 6 4 0 2 4 0 2 Output 0 Input 8 7 5 1 1 7 3 5 3 Output 16 Submitted Solution: ``` n = int(input()) A = list(map(int, input().split())) mod = 10 ** 9 + 7 flag = True if n%2 == 0: if 0 in A or len(set(A))!=n//2: flag = False else: if A.count(0)!=1 or len(set(A))!=n//2+1: flag = False if flag: print(2**(n//2) % mod) else: print(0) ```
instruction
0
89,118
11
178,236
Yes
output
1
89,118
11
178,237
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. Constraints * 1≦N≦10^5 * 0≦A_i≦N-1 Input The input is given from Standard Input in the following format: N A_1 A_2 ... A_N Output Print the number of the possible orders in which they were standing, modulo 10^9+7. Examples Input 5 2 4 4 0 2 Output 4 Input 7 6 4 0 2 4 0 2 Output 0 Input 8 7 5 1 1 7 3 5 3 Output 16 Submitted Solution: ``` n=int(input()) A=sorted((map(int,input().split()))) G=sorted([2*(i+1) for i in range(n//2)]*2+[0]) K=sorted([(2*i+1) for i in range(n//2)]*2) if n%2: if A!=G: print(0) exit() else: if A!=K: print(0) exit() print(2**(n//2)%(10**9+7)) ```
instruction
0
89,119
11
178,238
Yes
output
1
89,119
11
178,239
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. Constraints * 1≦N≦10^5 * 0≦A_i≦N-1 Input The input is given from Standard Input in the following format: N A_1 A_2 ... A_N Output Print the number of the possible orders in which they were standing, modulo 10^9+7. Examples Input 5 2 4 4 0 2 Output 4 Input 7 6 4 0 2 4 0 2 Output 0 Input 8 7 5 1 1 7 3 5 3 Output 16 Submitted Solution: ``` N = int(input()) A = [int(x) for x in input().split()] from collections import Counter def f(): cnt = Counter(A) m = N - 1 for k, v in cnt.items(): if k == 0 and v == 1: continue if v != 2 or k > m: return 0 return pow(2, N//2, 10**9 + 7) print(f()) ```
instruction
0
89,120
11
178,240
Yes
output
1
89,120
11
178,241
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. Constraints * 1≦N≦10^5 * 0≦A_i≦N-1 Input The input is given from Standard Input in the following format: N A_1 A_2 ... A_N Output Print the number of the possible orders in which they were standing, modulo 10^9+7. Examples Input 5 2 4 4 0 2 Output 4 Input 7 6 4 0 2 4 0 2 Output 0 Input 8 7 5 1 1 7 3 5 3 Output 16 Submitted Solution: ``` from collections import Counter N, *A = map(int, open(0).read().split()) l = [v for _, v in sorted(Counter(A).items())] if all(v == 2 for v in l[N % 2:]) and (N % 2 == 0 or l[0] == 1): print(2 ** (N // 2) % (10 ** 9 + 7)) else: print(0) ```
instruction
0
89,121
11
178,242
Yes
output
1
89,121
11
178,243
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. Constraints * 1≦N≦10^5 * 0≦A_i≦N-1 Input The input is given from Standard Input in the following format: N A_1 A_2 ... A_N Output Print the number of the possible orders in which they were standing, modulo 10^9+7. Examples Input 5 2 4 4 0 2 Output 4 Input 7 6 4 0 2 4 0 2 Output 0 Input 8 7 5 1 1 7 3 5 3 Output 16 Submitted Solution: ``` n=int(input()) a=list(map(int, input().split())) from collections import Counter c=Counter(a) cnt_lst=[0]*n for key in c: cnt_lst[key]+=c[key] flag=True if n%2==1: if cnt_lst[0]==1: cnt_lst.pop(0) for i in range(n-1): if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0): flag=False else: for i in range(n): if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0): flag=False print(2**(n//2) if flag else 0) ```
instruction
0
89,123
11
178,246
No
output
1
89,123
11
178,247
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. Constraints * 1≦N≦10^5 * 0≦A_i≦N-1 Input The input is given from Standard Input in the following format: N A_1 A_2 ... A_N Output Print the number of the possible orders in which they were standing, modulo 10^9+7. Examples Input 5 2 4 4 0 2 Output 4 Input 7 6 4 0 2 4 0 2 Output 0 Input 8 7 5 1 1 7 3 5 3 Output 16 Submitted Solution: ``` t = int(input()) m = list(map(int,input().split())) q={} z=False cnt0=0 for i in range(t): d=m[i] a=(t-1-d)//2 if d==0: cnt0+=1 if (a,a+d) not in q: q[(a,a+d)]=0 q[(a,a+d)]+=1 if q[(a,a+d)]>2: z=True break if z or cnt0>1: print(0) elif cnt0==1 and t%2==0: print(0) else: res=1 for i in q: if i[0]==i[1]: res=res*1 else: res=res*2 print(res) ```
instruction
0
89,124
11
178,248
No
output
1
89,124
11
178,249