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
|
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be n problems, sorted by difficulty, i.e. problem 1 is the easiest and problem n is the hardest. Limak knows it will take him 5·i minutes to solve the i-th problem.
Limak's friends organize a New Year's Eve party and Limak wants to be there at midnight or earlier. He needs k minutes to get there from his house, where he will participate in the contest first.
How many problems can Limak solve if he wants to make it to the party?
Input
The only line of the input contains two integers n and k (1 ≤ n ≤ 10, 1 ≤ k ≤ 240) — the number of the problems in the contest and the number of minutes Limak needs to get to the party from his house.
Output
Print one integer, denoting the maximum possible number of problems Limak can solve so that he could get to the party at midnight or earlier.
Examples
Input
3 222
Output
2
Input
4 190
Output
4
Input
7 1
Output
7
Note
In the first sample, there are 3 problems and Limak needs 222 minutes to get to the party. The three problems require 5, 10 and 15 minutes respectively. Limak can spend 5 + 10 = 15 minutes to solve first two problems. Then, at 20:15 he can leave his house to get to the party at 23:57 (after 222 minutes). In this scenario Limak would solve 2 problems. He doesn't have enough time to solve 3 problems so the answer is 2.
In the second sample, Limak can solve all 4 problems in 5 + 10 + 15 + 20 = 50 minutes. At 20:50 he will leave the house and go to the party. He will get there exactly at midnight.
In the third sample, Limak needs only 1 minute to get to the party. He has enough time to solve all 7 problems.
Submitted Solution:
```
# Details
'''
Contest: Good Bye 2016
Problem: New Year and Hurry
Rating: 800
Difficulty: A
Author: Sarthak Mittal
'''
# Input into int array
def arrin ():
return list(map(int,input().strip().split()))
# Printing int array
'''
def printer (a,n):
for i in range (0,n):
print(a[i], end = ' ')
print()
'''
# Array Minima
'''
def minima (a,n):
m = 0
for i in range (0,n):
if (a[i] <= a[m]):
m = i
return m
'''
# Array Sorter
'''
def sorter (a):
a.sort()
'''
# Rhetoric Printer
'''
def rhetoric (b):
if (b):
print('YES')
else:
print('NO')
'''
# String to List
'''
def strtolis (l,s):
for i in range (0,len(s)):
l.append(s[i])
'''
l = arrin()
n = l[0]
k = l[1]
k = 240 - k
time = 0
j = 0
while (time + 5 * j < k) and (j < n):
j += 1
time += 5 * j
print(j)
```
|
instruction
| 0
| 102,563
| 11
| 205,126
|
No
|
output
| 1
| 102,563
| 11
| 205,127
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be n problems, sorted by difficulty, i.e. problem 1 is the easiest and problem n is the hardest. Limak knows it will take him 5·i minutes to solve the i-th problem.
Limak's friends organize a New Year's Eve party and Limak wants to be there at midnight or earlier. He needs k minutes to get there from his house, where he will participate in the contest first.
How many problems can Limak solve if he wants to make it to the party?
Input
The only line of the input contains two integers n and k (1 ≤ n ≤ 10, 1 ≤ k ≤ 240) — the number of the problems in the contest and the number of minutes Limak needs to get to the party from his house.
Output
Print one integer, denoting the maximum possible number of problems Limak can solve so that he could get to the party at midnight or earlier.
Examples
Input
3 222
Output
2
Input
4 190
Output
4
Input
7 1
Output
7
Note
In the first sample, there are 3 problems and Limak needs 222 minutes to get to the party. The three problems require 5, 10 and 15 minutes respectively. Limak can spend 5 + 10 = 15 minutes to solve first two problems. Then, at 20:15 he can leave his house to get to the party at 23:57 (after 222 minutes). In this scenario Limak would solve 2 problems. He doesn't have enough time to solve 3 problems so the answer is 2.
In the second sample, Limak can solve all 4 problems in 5 + 10 + 15 + 20 = 50 minutes. At 20:50 he will leave the house and go to the party. He will get there exactly at midnight.
In the third sample, Limak needs only 1 minute to get to the party. He has enough time to solve all 7 problems.
Submitted Solution:
```
n_k = [int(i) for i in input().split()]
problems = n_k[0]
while(problems):
if(5*problems*(problems+1)/2) + n_k[1] <= 240:
print(problems)
break
else:
problems-=1
```
|
instruction
| 0
| 102,564
| 11
| 205,128
|
No
|
output
| 1
| 102,564
| 11
| 205,129
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be n problems, sorted by difficulty, i.e. problem 1 is the easiest and problem n is the hardest. Limak knows it will take him 5·i minutes to solve the i-th problem.
Limak's friends organize a New Year's Eve party and Limak wants to be there at midnight or earlier. He needs k minutes to get there from his house, where he will participate in the contest first.
How many problems can Limak solve if he wants to make it to the party?
Input
The only line of the input contains two integers n and k (1 ≤ n ≤ 10, 1 ≤ k ≤ 240) — the number of the problems in the contest and the number of minutes Limak needs to get to the party from his house.
Output
Print one integer, denoting the maximum possible number of problems Limak can solve so that he could get to the party at midnight or earlier.
Examples
Input
3 222
Output
2
Input
4 190
Output
4
Input
7 1
Output
7
Note
In the first sample, there are 3 problems and Limak needs 222 minutes to get to the party. The three problems require 5, 10 and 15 minutes respectively. Limak can spend 5 + 10 = 15 minutes to solve first two problems. Then, at 20:15 he can leave his house to get to the party at 23:57 (after 222 minutes). In this scenario Limak would solve 2 problems. He doesn't have enough time to solve 3 problems so the answer is 2.
In the second sample, Limak can solve all 4 problems in 5 + 10 + 15 + 20 = 50 minutes. At 20:50 he will leave the house and go to the party. He will get there exactly at midnight.
In the third sample, Limak needs only 1 minute to get to the party. He has enough time to solve all 7 problems.
Submitted Solution:
```
a, b = map(int, input().split())
n, x = 240 - b, 1
while n > 0:
n -= x * 5
x += 1
print(min(a, x))
```
|
instruction
| 0
| 102,565
| 11
| 205,130
|
No
|
output
| 1
| 102,565
| 11
| 205,131
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, b2, ..., bn] of length n each which he uses to ask people some quite peculiar questions.
To test you on how good are you at spotting inequality in life, he wants you to find an "unfair" subset of the original sequence. To be more precise, he wants you to select k numbers P = [p1, p2, ..., pk] such that 1 ≤ pi ≤ n for 1 ≤ i ≤ k and elements in P are distinct. Sequence P will represent indices of elements that you'll select from both sequences. He calls such a subset P "unfair" if and only if the following conditions are satisfied: 2·(ap1 + ... + apk) is greater than the sum of all elements from sequence A, and 2·(bp1 + ... + bpk) is greater than the sum of all elements from the sequence B. Also, k should be smaller or equal to <image> because it will be to easy to find sequence P if he allowed you to select too many elements!
Mike guarantees you that a solution will always exist given the conditions described above, so please help him satisfy his curiosity!
Input
The first line contains integer n (1 ≤ n ≤ 105) — the number of elements in the sequences.
On the second line there are n space-separated integers a1, ..., an (1 ≤ ai ≤ 109) — elements of sequence A.
On the third line there are also n space-separated integers b1, ..., bn (1 ≤ bi ≤ 109) — elements of sequence B.
Output
On the first line output an integer k which represents the size of the found subset. k should be less or equal to <image>.
On the next line print k integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the elements of sequence P. You can print the numbers in any order you want. Elements in sequence P should be distinct.
Example
Input
5
8 7 4 8 3
4 2 5 3 7
Output
3
1 4 5
Submitted Solution:
```
n = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
idAB = zip(range(n), A, B)
idAB = sorted(idAB, key=lambda x: x[1], reverse=True)
ans = [idAB[0][0] + 1]
for i in range(1, n, 2):
choice = max(idAB[i:i + 2], key=lambda x: x[2])
ans.append(choice[0] + 1)
ans = sorted(ans)
print(len(ans))
print(*ans)
```
|
instruction
| 0
| 102,574
| 11
| 205,148
|
Yes
|
output
| 1
| 102,574
| 11
| 205,149
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, b2, ..., bn] of length n each which he uses to ask people some quite peculiar questions.
To test you on how good are you at spotting inequality in life, he wants you to find an "unfair" subset of the original sequence. To be more precise, he wants you to select k numbers P = [p1, p2, ..., pk] such that 1 ≤ pi ≤ n for 1 ≤ i ≤ k and elements in P are distinct. Sequence P will represent indices of elements that you'll select from both sequences. He calls such a subset P "unfair" if and only if the following conditions are satisfied: 2·(ap1 + ... + apk) is greater than the sum of all elements from sequence A, and 2·(bp1 + ... + bpk) is greater than the sum of all elements from the sequence B. Also, k should be smaller or equal to <image> because it will be to easy to find sequence P if he allowed you to select too many elements!
Mike guarantees you that a solution will always exist given the conditions described above, so please help him satisfy his curiosity!
Input
The first line contains integer n (1 ≤ n ≤ 105) — the number of elements in the sequences.
On the second line there are n space-separated integers a1, ..., an (1 ≤ ai ≤ 109) — elements of sequence A.
On the third line there are also n space-separated integers b1, ..., bn (1 ≤ bi ≤ 109) — elements of sequence B.
Output
On the first line output an integer k which represents the size of the found subset. k should be less or equal to <image>.
On the next line print k integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the elements of sequence P. You can print the numbers in any order you want. Elements in sequence P should be distinct.
Example
Input
5
8 7 4 8 3
4 2 5 3 7
Output
3
1 4 5
Submitted Solution:
```
import sys
input = sys.stdin.readline
n=int(input())
arr=list(map(int,input().split()))
brr=list(map(int,input().split()))
ida=list(range(n))
print((n>>1)+1)
an=[]
ida.sort(key=lambda x: -arr[x])
an.append(ida[0]+1)
for i in range(1,n,2):
if n-1==i:
an.append(ida[i]+1)
elif brr[ida[i]]>=brr[ida[i+1]]:
an.append(ida[i]+1)
else:
an.append(ida[i+1]+1)
print(*an)
```
|
instruction
| 0
| 102,575
| 11
| 205,150
|
Yes
|
output
| 1
| 102,575
| 11
| 205,151
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, b2, ..., bn] of length n each which he uses to ask people some quite peculiar questions.
To test you on how good are you at spotting inequality in life, he wants you to find an "unfair" subset of the original sequence. To be more precise, he wants you to select k numbers P = [p1, p2, ..., pk] such that 1 ≤ pi ≤ n for 1 ≤ i ≤ k and elements in P are distinct. Sequence P will represent indices of elements that you'll select from both sequences. He calls such a subset P "unfair" if and only if the following conditions are satisfied: 2·(ap1 + ... + apk) is greater than the sum of all elements from sequence A, and 2·(bp1 + ... + bpk) is greater than the sum of all elements from the sequence B. Also, k should be smaller or equal to <image> because it will be to easy to find sequence P if he allowed you to select too many elements!
Mike guarantees you that a solution will always exist given the conditions described above, so please help him satisfy his curiosity!
Input
The first line contains integer n (1 ≤ n ≤ 105) — the number of elements in the sequences.
On the second line there are n space-separated integers a1, ..., an (1 ≤ ai ≤ 109) — elements of sequence A.
On the third line there are also n space-separated integers b1, ..., bn (1 ≤ bi ≤ 109) — elements of sequence B.
Output
On the first line output an integer k which represents the size of the found subset. k should be less or equal to <image>.
On the next line print k integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the elements of sequence P. You can print the numbers in any order you want. Elements in sequence P should be distinct.
Example
Input
5
8 7 4 8 3
4 2 5 3 7
Output
3
1 4 5
Submitted Solution:
```
import random
import datetime
random.seed( datetime.datetime.now() )
N = int( input() )
A = list( map( int, input().split() ) )
B = list( map( int, input().split() ) )
def valid( arr ):
return sum( A[ k ] for k in arr ) * 2 > sum( A ) and sum( B[ k ] for k in arr ) * 2 > sum( B )
ans = [ i for i in range( N ) ]
while not valid( ans[ : N // 2 + 1 ] ):
random.shuffle( ans )
print( N // 2 + 1 )
print( *list( map( lambda x: x + 1, ans[ : N // 2 + 1 ] ) ) )
```
|
instruction
| 0
| 102,576
| 11
| 205,152
|
Yes
|
output
| 1
| 102,576
| 11
| 205,153
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, b2, ..., bn] of length n each which he uses to ask people some quite peculiar questions.
To test you on how good are you at spotting inequality in life, he wants you to find an "unfair" subset of the original sequence. To be more precise, he wants you to select k numbers P = [p1, p2, ..., pk] such that 1 ≤ pi ≤ n for 1 ≤ i ≤ k and elements in P are distinct. Sequence P will represent indices of elements that you'll select from both sequences. He calls such a subset P "unfair" if and only if the following conditions are satisfied: 2·(ap1 + ... + apk) is greater than the sum of all elements from sequence A, and 2·(bp1 + ... + bpk) is greater than the sum of all elements from the sequence B. Also, k should be smaller or equal to <image> because it will be to easy to find sequence P if he allowed you to select too many elements!
Mike guarantees you that a solution will always exist given the conditions described above, so please help him satisfy his curiosity!
Input
The first line contains integer n (1 ≤ n ≤ 105) — the number of elements in the sequences.
On the second line there are n space-separated integers a1, ..., an (1 ≤ ai ≤ 109) — elements of sequence A.
On the third line there are also n space-separated integers b1, ..., bn (1 ≤ bi ≤ 109) — elements of sequence B.
Output
On the first line output an integer k which represents the size of the found subset. k should be less or equal to <image>.
On the next line print k integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the elements of sequence P. You can print the numbers in any order you want. Elements in sequence P should be distinct.
Example
Input
5
8 7 4 8 3
4 2 5 3 7
Output
3
1 4 5
Submitted Solution:
```
from sys import stdin, stdout
import random
n = int(stdin.readline().rstrip())
a = stdin.readline().rstrip().split()
a = [int(x) for x in a]
b = stdin.readline().rstrip().split()
b = [int(x) for x in b]
currentSeq = [(a[0],b[0],1)]
stock=0
i=1
seqTotal = [a[0],b[0]]
listTotal = [a[0],b[0]]
while i<n:
if i%2==1:
stock+=1
listTotal[0]+=a[i]; listTotal[1]+=b[i]
if (2*seqTotal[0]<=listTotal[0] or 2*seqTotal[1]<=listTotal[1]) and stock>0:
stock-=1
seqTotal[0]+=a[i]; seqTotal[1]+=b[i]
currentSeq.append((a[i],b[i],i+1))
elif 2*seqTotal[0]<=listTotal[0] or 2*seqTotal[1]<=listTotal[1]:
seqTotal[0]+=a[i]; seqTotal[1]+=b[i]
currentSeq.append((a[i],b[i],i+1))
random.shuffle(currentSeq)
for j in range(len(currentSeq)):
if 2*(seqTotal[0]-currentSeq[j][0])>listTotal[0] and 2*(seqTotal[1]-currentSeq[j][1])>listTotal[1]:
seqTotal[0]-=currentSeq[j][0]
seqTotal[1]-=currentSeq[j][1]
currentSeq.pop(j)
break
i+=1
c = [str(x[2]) for x in currentSeq]
print(len(c))
print(' '.join(c))
```
|
instruction
| 0
| 102,577
| 11
| 205,154
|
Yes
|
output
| 1
| 102,577
| 11
| 205,155
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, b2, ..., bn] of length n each which he uses to ask people some quite peculiar questions.
To test you on how good are you at spotting inequality in life, he wants you to find an "unfair" subset of the original sequence. To be more precise, he wants you to select k numbers P = [p1, p2, ..., pk] such that 1 ≤ pi ≤ n for 1 ≤ i ≤ k and elements in P are distinct. Sequence P will represent indices of elements that you'll select from both sequences. He calls such a subset P "unfair" if and only if the following conditions are satisfied: 2·(ap1 + ... + apk) is greater than the sum of all elements from sequence A, and 2·(bp1 + ... + bpk) is greater than the sum of all elements from the sequence B. Also, k should be smaller or equal to <image> because it will be to easy to find sequence P if he allowed you to select too many elements!
Mike guarantees you that a solution will always exist given the conditions described above, so please help him satisfy his curiosity!
Input
The first line contains integer n (1 ≤ n ≤ 105) — the number of elements in the sequences.
On the second line there are n space-separated integers a1, ..., an (1 ≤ ai ≤ 109) — elements of sequence A.
On the third line there are also n space-separated integers b1, ..., bn (1 ≤ bi ≤ 109) — elements of sequence B.
Output
On the first line output an integer k which represents the size of the found subset. k should be less or equal to <image>.
On the next line print k integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the elements of sequence P. You can print the numbers in any order you want. Elements in sequence P should be distinct.
Example
Input
5
8 7 4 8 3
4 2 5 3 7
Output
3
1 4 5
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ab = list(zip(a, b, [i for i in range(1, n + 1)]))
ba = list(zip(b, a, [i for i in range(1, n + 1)]))
ab.sort(key = lambda x: (-x[0], -x[1]))
ba.sort(key = lambda x: (-x[0], -x[1]))
accA, accB = 0, 0
sumA, sumB = sum(a), sum(b)
g50A, g50B = sumA // 2 + 1, sumB // 2 + 1
maxK = n // 2 + 1
k = 0
ans = set([])
p1, p2 = 0, 0
# print(ab, ba)
while k < maxK:
if (min((accA + ab[p1][0]), g50A) + min((accB + ab[p1][1]), g50B)) <= \
(min((accA + ba[p2][1]), g50A) + min((accB + ba[p2][0], g50B))):
ans.add(ab[p1][2])
accA += ab[p1][0]
accB += ab[p1][1]
while ab[p1][2] in ans:
p1 += 1
else:
ans.add(ba[p2][2])
accB += ba[p2][0]
accA += ba[p2][1]
while ba[p2][2] in ans:
p2 += 1
k += 1
print(k)
print(' '.join(list(map(str, list(ans)))))
```
|
instruction
| 0
| 102,578
| 11
| 205,156
|
No
|
output
| 1
| 102,578
| 11
| 205,157
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, b2, ..., bn] of length n each which he uses to ask people some quite peculiar questions.
To test you on how good are you at spotting inequality in life, he wants you to find an "unfair" subset of the original sequence. To be more precise, he wants you to select k numbers P = [p1, p2, ..., pk] such that 1 ≤ pi ≤ n for 1 ≤ i ≤ k and elements in P are distinct. Sequence P will represent indices of elements that you'll select from both sequences. He calls such a subset P "unfair" if and only if the following conditions are satisfied: 2·(ap1 + ... + apk) is greater than the sum of all elements from sequence A, and 2·(bp1 + ... + bpk) is greater than the sum of all elements from the sequence B. Also, k should be smaller or equal to <image> because it will be to easy to find sequence P if he allowed you to select too many elements!
Mike guarantees you that a solution will always exist given the conditions described above, so please help him satisfy his curiosity!
Input
The first line contains integer n (1 ≤ n ≤ 105) — the number of elements in the sequences.
On the second line there are n space-separated integers a1, ..., an (1 ≤ ai ≤ 109) — elements of sequence A.
On the third line there are also n space-separated integers b1, ..., bn (1 ≤ bi ≤ 109) — elements of sequence B.
Output
On the first line output an integer k which represents the size of the found subset. k should be less or equal to <image>.
On the next line print k integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the elements of sequence P. You can print the numbers in any order you want. Elements in sequence P should be distinct.
Example
Input
5
8 7 4 8 3
4 2 5 3 7
Output
3
1 4 5
Submitted Solution:
```
n = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
idAB = zip(range(n), A, B)
idAB = sorted(idAB, key=lambda x: x[1], reverse=True)
real_sort = []
for i, elem in enumerate(idAB):
if i == n-1:
real_sort.append(n)
else:
choice = max(idAB[i], idAB[i + 1], key=lambda x: x[2])
real_sort.append(choice[0] + 1)
if choice[0] != i:
i += 1
ans = real_sort[:n // 2 + 1]
ans = sorted(ans)
print(*ans)
```
|
instruction
| 0
| 102,579
| 11
| 205,158
|
No
|
output
| 1
| 102,579
| 11
| 205,159
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, b2, ..., bn] of length n each which he uses to ask people some quite peculiar questions.
To test you on how good are you at spotting inequality in life, he wants you to find an "unfair" subset of the original sequence. To be more precise, he wants you to select k numbers P = [p1, p2, ..., pk] such that 1 ≤ pi ≤ n for 1 ≤ i ≤ k and elements in P are distinct. Sequence P will represent indices of elements that you'll select from both sequences. He calls such a subset P "unfair" if and only if the following conditions are satisfied: 2·(ap1 + ... + apk) is greater than the sum of all elements from sequence A, and 2·(bp1 + ... + bpk) is greater than the sum of all elements from the sequence B. Also, k should be smaller or equal to <image> because it will be to easy to find sequence P if he allowed you to select too many elements!
Mike guarantees you that a solution will always exist given the conditions described above, so please help him satisfy his curiosity!
Input
The first line contains integer n (1 ≤ n ≤ 105) — the number of elements in the sequences.
On the second line there are n space-separated integers a1, ..., an (1 ≤ ai ≤ 109) — elements of sequence A.
On the third line there are also n space-separated integers b1, ..., bn (1 ≤ bi ≤ 109) — elements of sequence B.
Output
On the first line output an integer k which represents the size of the found subset. k should be less or equal to <image>.
On the next line print k integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the elements of sequence P. You can print the numbers in any order you want. Elements in sequence P should be distinct.
Example
Input
5
8 7 4 8 3
4 2 5 3 7
Output
3
1 4 5
Submitted Solution:
```
from sys import stdin, stdout
import random
n = int(stdin.readline().rstrip())
a = stdin.readline().rstrip().split()
a = [int(x) for x in a]
b = stdin.readline().rstrip().split()
b = [int(x) for x in b]
currentSeq = [(a[0],b[0],1)]
stock=0
i=1
seqTotal = [a[0],b[0]]
listTotal = [a[0],b[0]]
while i<n:
if i%2==1:
stock+=1
listTotal[0]+=a[i]; listTotal[1]+=b[i]
if (2*seqTotal[0]<=listTotal[0] or 2*seqTotal[1]<=listTotal[1]) and stock>=0:
stock-=1
seqTotal[0]+=a[i]; seqTotal[1]+=b[i]
currentSeq.append((a[i],b[i],i+1))
elif 2*seqTotal[0]<=listTotal[0] or 2*seqTotal[1]<=listTotal[1]:
seqTotal[0]+=a[i]; seqTotal[1]+=b[i]
currentSeq.append((a[i],b[i],i+1))
random.shuffle(currentSeq)
for j in range(len(currentSeq)):
if 2*seqTotal[0]-currentSeq[j][0]>listTotal[0] and 2*seqTotal[1]-currentSeq[j][1]>listTotal[1]:
currentSeq.pop(j)
break
i+=1
c = [str(i[2]) for i in currentSeq]
print(len(c))
print(' '.join(c))
```
|
instruction
| 0
| 102,580
| 11
| 205,160
|
No
|
output
| 1
| 102,580
| 11
| 205,161
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, b2, ..., bn] of length n each which he uses to ask people some quite peculiar questions.
To test you on how good are you at spotting inequality in life, he wants you to find an "unfair" subset of the original sequence. To be more precise, he wants you to select k numbers P = [p1, p2, ..., pk] such that 1 ≤ pi ≤ n for 1 ≤ i ≤ k and elements in P are distinct. Sequence P will represent indices of elements that you'll select from both sequences. He calls such a subset P "unfair" if and only if the following conditions are satisfied: 2·(ap1 + ... + apk) is greater than the sum of all elements from sequence A, and 2·(bp1 + ... + bpk) is greater than the sum of all elements from the sequence B. Also, k should be smaller or equal to <image> because it will be to easy to find sequence P if he allowed you to select too many elements!
Mike guarantees you that a solution will always exist given the conditions described above, so please help him satisfy his curiosity!
Input
The first line contains integer n (1 ≤ n ≤ 105) — the number of elements in the sequences.
On the second line there are n space-separated integers a1, ..., an (1 ≤ ai ≤ 109) — elements of sequence A.
On the third line there are also n space-separated integers b1, ..., bn (1 ≤ bi ≤ 109) — elements of sequence B.
Output
On the first line output an integer k which represents the size of the found subset. k should be less or equal to <image>.
On the next line print k integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the elements of sequence P. You can print the numbers in any order you want. Elements in sequence P should be distinct.
Example
Input
5
8 7 4 8 3
4 2 5 3 7
Output
3
1 4 5
Submitted Solution:
```
z = input()
x = input().split(' ')
y = input().split(' ')
x = list(map(int, x))
y = list(map(int, y))
n = len(x)
def Quicksort(a,c, p, q):
if(p < q):
r = Partition(a,c, p ,q)
Quicksort(a,c, p, r-1)
Quicksort(a,c, r+1, q)
def Partition(a,c, p ,q):
pivot = a[p]
i = p+1
j = q
done = False
while not done:
while i <= j and a[i] >= pivot:
i += 1
while i <= j and a[j] <= pivot:
j -= 1
if j < i:
done = True
else:
# swap places
a[i], a[j] = swap(a[i], a[j])
c[i], c[j] = swap(c[i], c[j])
# swap start with myList[right]
a[p], a[j] = swap(a[p], a[j])
c[p], c[j] = swap(c[p], c[j])
return j
def swap(a, b):
return b, a
c = []
for i in range(n):
c.append(i)
Quicksort(x,c, 0, n-1)
pick = [c[0]]
if len(c) % 2 == 0:
for i in range(1, n-1, 2):
if y[c[i]] > y[c[i+1]]:
pick.append(c[i])
else:
pick.append(c[i+1])
pick.append(c[len(x)-1])
else:
for i in range(1, n, 2):
if y[c[i]] > y[c[i+1]]:
pick.append(c[i])
else:
pick.append(c[i+1])
#print(len(pick))
for i in range(len(pick)):
print(pick[i]+1, end=" ")
```
|
instruction
| 0
| 102,581
| 11
| 205,162
|
No
|
output
| 1
| 102,581
| 11
| 205,163
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
n = int(input())
l = [ list(map(int, input().split())) for _ in range(n) ]
c = 0
l.sort(key=lambda x: x[1])
for i in range(n):
c += l[i][0]
if c > l[i][1]:
print("No")
exit()
print("Yes")
```
|
instruction
| 0
| 102,744
| 11
| 205,488
|
Yes
|
output
| 1
| 102,744
| 11
| 205,489
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x: (x[1], x[0]))
s = 0
for t in AB:
s += t[0]
if (s > t[1]):
print('No')
quit()
print('Yes')
```
|
instruction
| 0
| 102,745
| 11
| 205,490
|
Yes
|
output
| 1
| 102,745
| 11
| 205,491
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
N = int(input())
W = []
for _ in range(N):
a, b = map(int, input().split())
W.append([a, b])
s = 0
for a, b in sorted(W, key=lambda x: x[1]):
s += a
if s > b:
print('No')
quit()
print('Yes')
```
|
instruction
| 0
| 102,746
| 11
| 205,492
|
Yes
|
output
| 1
| 102,746
| 11
| 205,493
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[1])
jikoku=0
for i in range(n):
jikoku+=ab[i][0]
if jikoku>ab[i][1]:
print('No')
exit()
print('Yes')
```
|
instruction
| 0
| 102,747
| 11
| 205,494
|
Yes
|
output
| 1
| 102,747
| 11
| 205,495
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
def main():
n = int(input())
ls = []
for _ in range(n):
a, b = map(int, input().split())
ls.append([b,a])
ls = ls.sort()
t=0
for i in ls:
t += i[1]
if t > i[0]:
print('No')
exit(0)
print('Yes')
if __name__ == '__main__':
main()
```
|
instruction
| 0
| 102,748
| 11
| 205,496
|
No
|
output
| 1
| 102,748
| 11
| 205,497
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
n = int(input())
a_lst = []
b_lst = []
for i in range(0, n):
a, b = [int(elem) for elem in input().split()]
a_lst.append(a)
b_lst.append(b)
tmp = zip(b_lst, a_lst)
tmp = sorted(tmp)
b_lst, a_lst = zip(*tmp)
print(b_lst, a_lst)
flag = 0
sums = 0
for i in range(0, len(a_lst)):
sums += a_lst[i]
if sums > b_lst[i]:
flag = 1
break
if flag == 0:
print("Yes")
else:
print("No")
```
|
instruction
| 0
| 102,749
| 11
| 205,498
|
No
|
output
| 1
| 102,749
| 11
| 205,499
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
import sys
n = int(input())
li = sorted(map(lambda x: list(map(int, x.split()[::-1])), sys.stdin.readlines()))
print(li)
sum = 0
flag = "Yes"
for x, y in li:
sum += y
if x < sum:
flag = "No"
break
print(flag)
```
|
instruction
| 0
| 102,750
| 11
| 205,500
|
No
|
output
| 1
| 102,750
| 11
| 205,501
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
N = int(input())
task = []
for i in range(N):
M = list(map(int,input().split()))
M[0],M[1]=M[1],M[0]
task.append(M)
task.sort()
K = 0
ans = 1
for i in range(N):
K += task[i,1]
if (K>task[i,0]):
ans = 0
break
if ans:
print("Yes")
else:
print("No")
```
|
instruction
| 0
| 102,751
| 11
| 205,502
|
No
|
output
| 1
| 102,751
| 11
| 205,503
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Input Format
The input format is following:
n m q
a_1 a_2 ... a_q
Output Format
Print the number of connected part in one line.
Constraints
* n ≤ 10^{12}
* 7n is divisible by m.
* 1 ≤ q ≤ m ≤ 10^5
* 0 ≤ a_1 < a_2 < ... < a_q < m
Scoring
Subtask 1 [100 points]
* n ≤ 100000.
Subtask 2 [90 points]
* m is divisible by 7.
* a_{i + 1} - a_i = 1.
Subtask 3 [200 points]
* m is divisible by 7.
Subtask 4 [110 points]
* There are no additional constraints.
Sample Input 1
7 7 3
1 3 5
Sample Output 1
4
The calendar looks like this:
<image>
Sample Input 2
10 14 8
5 6 7 8 9 10 11 12
Sample Output 2
10
The calendar looks like this:
<image>
Output Format
Print the number of connected part in one line.
Constraints
* n ≤ 10^{12}
* 7n is divisible by m.
* 1 ≤ q ≤ m ≤ 10^5
* 0 ≤ a_1 < a_2 < ... < a_q < m
Scoring
Subtask 1 [100 points]
* n ≤ 100000.
Subtask 2 [90 points]
* m is divisible by 7.
* a_{i + 1} - a_i = 1.
Subtask 3 [200 points]
* m is divisible by 7.
Subtask 4 [110 points]
* There are no additional constraints.
Input Format
The input format is following:
n m q
a_1 a_2 ... a_q
Examples
Input
7 7 3
1 3 5
Output
4
Input
10 14 8
5 6 7 8 9 10 11 12
Output
10
Submitted Solution:
```
from queue import Queue
n,m,q=map(int,input().split())
a=list(map(int,input().split()))
def count_group(size):
cc = [False]*size
for i in range(q):
j = 0
while a[i]+m*j < size:
cc[a[i]+m*j] = True
j += 1
gg = [0]*size
ox = [-1, 0, 1, 0]
oy = [0, -7, 0, 7]
def bfs(i, g):
qq = Queue()
qq.put(i, False)
while not qq.empty():
ii = qq.get(False)
gg[ii] = g
for t in range(4):
if ii % 7 == 0 and ox[t] == -1: continue
if (ii+1) % 7 == 0 and ox[t] == 1: continue
j = ii+ox[t]+oy[t]
if 0 <= j < size:
if cc[j] or gg[j] != 0: continue
qq.put(j, False)
maxg = 0
for i in range(size):
if not cc[i] and gg[i] == 0:
maxg += 1
bfs(i, maxg)
return maxg
block = (m+7)//7*7*7
if n*7 <= block:
print(count_group(n*7))
exit(0)
c1 = count_group(block)
c2 = count_group(block*2)
c3 = count_group(block+((n*7)%block))
print(c1 + ((n*7-block)//block)*(c2-c1) + (c3-c1))
```
|
instruction
| 0
| 102,801
| 11
| 205,602
|
No
|
output
| 1
| 102,801
| 11
| 205,603
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
|
instruction
| 0
| 103,045
| 11
| 206,090
|
Tags: constructive algorithms, greedy, implementation, math
Correct Solution:
```
N, K = map(int, input().split())
def f(k):
r = 0
for i in range(1, k):
r += i//2
return r
mx, mn = N+2, 0
idx = N//2
while mx-mn>1:
if f(idx) < K:
idx, mn = (idx+mx)//2, idx
continue
idx, mx = (idx+mn)//2, idx
#print(N, K)
#print(idx, f(idx), f(idx+1))
if idx+1 > N:
print(-1)
import sys
sys.exit()
rs = []
for i in range(idx):
rs.append(i+1)
rs.append(idx+1+2*(f(idx+1)-K))
#print(*rs)
rs2 = []
for i in range(N-(idx+1)):
rs2.append(5000+i)
rs = [10000*x for x in rs]
print(*(rs2 + rs))
```
|
output
| 1
| 103,045
| 11
| 206,091
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
|
instruction
| 0
| 103,046
| 11
| 206,092
|
Tags: constructive algorithms, greedy, implementation, math
Correct Solution:
```
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
x=(n-3)//2
MAX=x*(x+1)
if n%2==1:
MAX+=(n-1)//2
else:
MAX+=(n-1)//2*2
#print(MAX)
if m>MAX:
print(-1)
sys.exit()
score=0
x=1
while score<m:
x+=1
score+=(x-1)//2
#print(x,score)
LAST1=x
x+=(score-m)*2
ANS=list(range(1,LAST1))
ANS.append(x)
for i in range(n-len(ANS)):
ANS.append(10**9-i*25001-1)
print(*sorted(ANS))
```
|
output
| 1
| 103,046
| 11
| 206,093
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
|
instruction
| 0
| 103,047
| 11
| 206,094
|
Tags: constructive algorithms, greedy, implementation, math
Correct Solution:
```
def main():
n, m = map(int, input().split())
x = []
i = 1
while (n > 0 and m >= len(x) // 2):
m -= len(x) // 2
n -= 1
x.append(i)
i += 1
k = i - 1
if (m == 0 and n == 0):
print(*x)
return
elif (n == 0):
print(-1)
return
else:
x.append(2 * k - m * 2)
n -= 1
for i in range(n):
x.append(20000 * (i + 1) + 1)
print(*x)
main()
```
|
output
| 1
| 103,047
| 11
| 206,095
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
|
instruction
| 0
| 103,048
| 11
| 206,096
|
Tags: constructive algorithms, greedy, implementation, math
Correct Solution:
```
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
from decimal import Decimal
# from fractions import Fraction
# sys.setrecursionlimit(100000)
mod = int(1e9) + 7
INF=10**8
n,m=mdata()
if n==1 and m==0:
out(1)
exit()
l=[]
k=math.floor(((1+4*m)**0.5-1)/2)
if k>n:
out(-1)
exit()
l=list(range(1,2*k+3))
m-=k*(k+1)
while m:
l.append(l[-1]+l[max(0,l[-1]-2*m)])
m-=min(m,l[-1]//2)
if len(l)>n:
out(-1)
exit()
i=0
t=l[-1]
while len(l)<n:
l.append(INF+i*(t+1))
i+=1
outl(l)
```
|
output
| 1
| 103,048
| 11
| 206,097
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
|
instruction
| 0
| 103,049
| 11
| 206,098
|
Tags: constructive algorithms, greedy, implementation, math
Correct Solution:
```
# https://codeforces.com/problemset/problem/1305/E
def gen_sequence(size, balance):
result = []
for i in range(1, size + 1):
triple_count = (i - 1) >> 1
if triple_count <= balance:
result.append(i)
balance -= triple_count
else:
break
if len(result) == size and balance > 0:
return [-1]
if balance > 0:
result.append(2 * (result[-1] - balance) + 1)
delta = result[-1] + 1
while len(result) < size:
value = result[-1] + delta
if value % 2 == 0:
value += 1
result.append(value)
return result
if __name__ == '__main__':
size, balance = map(int, input().split())
for x in gen_sequence(size, balance):
print(x, end=' ')
print()
```
|
output
| 1
| 103,049
| 11
| 206,099
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
|
instruction
| 0
| 103,050
| 11
| 206,100
|
Tags: constructive algorithms, greedy, implementation, math
Correct Solution:
```
n, m = map(int, input().split())
out = []
currCount = 0
currVal = 0
while currVal < n:
nex = currVal // 2
if nex + currCount <= m:
currCount += nex
currVal += 1
out.append(currVal)
else:
break
need = m - currCount
if need > 0:
nex = currVal // 2
val = currVal + 1
val += 2 * (nex - need)
if nex > need:
out.append(val)
currCount += need
l = len(out)
if l > n or m != currCount:
assert(m > ((n-1) * (n-1))//4)
print(-1)
else:
assert(m <= ((n-1) * (n-1))//4)
lorg = max(out)
diff = lorg + 1
start = (lorg+diff)//diff
start += 2
start *= diff
start += 1
while l < n:
l += 1
out.append(start)
start += diff
assert(len(out) == n)
for i in range(n - 1):
assert(out[i] < out[i + 1])
assert(1 <= out[i])
assert(out[i + 1] <= 10 ** 9)
thing = set(out)
count = 0
for i in range(n):
for j in range(i + 1, n):
if out[i] + out[j] in thing:
count += 1
assert(count == m)
print(' '.join(map(str,out)))
```
|
output
| 1
| 103,050
| 11
| 206,101
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
|
instruction
| 0
| 103,051
| 11
| 206,102
|
Tags: constructive algorithms, greedy, implementation, math
Correct Solution:
```
n, m = map(int, input().split())
numList = [x+1 for x in range(n)]
backdoor = []
count = sum([(i-1) // 2 for i in range(1, n+1)])
if count < m: exit(print(-1))
while count > m:
lastpop = numList.pop()
count -= (lastpop - 1) // 2
if count >= m:
if len(backdoor) == 0: backdoor.append(10 ** 9)
else: backdoor.append(backdoor[-1] - 2 ** 16)
else:
gap = m - count
backdoor.append(2 * (lastpop - gap) - 1)
count += gap
while len(backdoor) > 0: numList.append(backdoor.pop())
print(' '.join([str(x) for x in numList]))
```
|
output
| 1
| 103,051
| 11
| 206,103
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
|
instruction
| 0
| 103,052
| 11
| 206,104
|
Tags: constructive algorithms, greedy, implementation, math
Correct Solution:
```
import math
import sys
n,m=[int(s) for s in input().split()]
ans=[]
curr_balance=0
for i in range(1,n+1):
new_balance=math.floor((i-1)/2);
if curr_balance+new_balance > m:
break
curr_balance+=new_balance;
ans.append(i);
if curr_balance<m:
if len(ans)==n:
print(-1)
sys.exit()
remaining_balance = m-curr_balance
number_index = remaining_balance*2 - 1
if ans[-1-number_index]+ans[-1] <= 1000000000:
ans.append(ans[-1-number_index]+ans[-1])
num_to_add=ans[-1]+1
for i in range(len(ans)+1,n+1):
if ans[-1]+num_to_add <= 1000000000:
ans.append(ans[-1]+num_to_add)
else:
break;
if len(ans)<n:
print(-1)
sys.exit()
for i in ans:
print(i," ")
```
|
output
| 1
| 103,052
| 11
| 206,105
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
Submitted Solution:
```
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
x=(n-3)//2
MAX=x*(x+1)
if n%2==1:
MAX+=(n-1)//2
else:
MAX+=(n-1)//2*2
#print(MAX)
if m>MAX:
print(-1)
sys.exit()
score=0
x=1
while score<m:
x+=1
score+=(x-1)//2
#print(x,score)
LAST1=x
x+=(score-m)*2
ANS=list(range(1,LAST1))
ANS.append(x)
for i in range(n-len(ANS)):
ANS.append(10**9-i*5001-1)
print(*sorted(ANS))
```
|
instruction
| 0
| 103,053
| 11
| 206,106
|
Yes
|
output
| 1
| 103,053
| 11
| 206,107
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
Submitted Solution:
```
from sys import stdin
from bisect import bisect_left as bl
from bisect import bisect_right as br
def input():
return stdin.readline()[:-1]
def intput():
return int(input())
def sinput():
return input().split()
def intsput():
return map(int, sinput())
class RangedList:
def __init__(self, start, stop, val=0):
self.shift = 0 - start
self.start = start
self.stop = stop
self.list = [val] * (stop - start)
def __setitem__(self, key, value):
self.list[key + self.shift] = value
def __getitem__(self, key):
return self.list[key + self.shift]
def __repr__(self):
return str(self.list)
def __iter__(self):
return iter(self.list)
def dprint(*args, **kwargs):
if debugging:
print(*args, **kwargs)
def sigma(x):
return x * (x + 1) // 2
def maxbalance(x):
if x % 2 == 0:
return sigma(x // 2 - 1) * 2
else:
x += 1
return sigma(x // 2 - 1) * 2 - x // 2 + 1
debugging = 1
# Code
n, balance = intsput()
if maxbalance(n) < balance:
print(-1)
exit()
else:
if n == 2:
print('1 2')
exit()
elif n == 1:
print('1')
exit()
largest = 2
dist = [1, 2]
k = 1
while len(dist) < n:
if balance:
x = dist[-1] + 1
can_create = (x - 1) // 2
if can_create <= balance:
dist.append(x)
balance -= can_create
largest = x
else:
dist.append(dist[- (balance * 2)] + dist[-1])
balance = 0
#used = set(dist)
else:
dist.append(10 ** 8 + 10 ** 4 * k + 1)
k += 1
print(*dist)
```
|
instruction
| 0
| 103,054
| 11
| 206,108
|
Yes
|
output
| 1
| 103,054
| 11
| 206,109
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
Submitted Solution:
```
dic={}
count=0
for i in range(1,5001):
count+=(i-1)//2
dic[i]=count
n,m=map(int,input().split())
if(m>dic[n]):print(-1)
elif(m==0):
print(*[450000000+i for i in range(n)])
else:
ls=[]
flag=False
for i in range(1,5001):
if(dic[i]>m):
flag=True
break
else:
ls.append(i)
if(flag):m-=dic[i-1]
else:m-=dic[i]
if(m):ls.append(ls[-1]+ls[-2*m])
if(len(ls)<=n):
x=ls[-1]+ls[-2*m]
for i in range(n-len(ls)):
ls.append(10**7+x*i)
ls.sort()
print(*ls)
else:
print(-1)
```
|
instruction
| 0
| 103,055
| 11
| 206,110
|
Yes
|
output
| 1
| 103,055
| 11
| 206,111
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
Submitted Solution:
```
n, m = map(int, input().split(' '))
limit = 0
for i in range(3, n + 1):
limit += (i - 1) // 2
if m > limit:
print(-1)
else:
a = [i for i in range(1, n + 1)]
count = limit
i = n
while count > m:
curr = (i - 1) // 2
to_del = min(curr, count - m)
if to_del == curr:
a[i - 1] = 1000000000 - (n - i) * 10000
else:
a[i - 1] = a[i - 2] + a[i - 1 - 2 * (curr - to_del)]
count -= to_del
i -= 1
print(' '.join(map(str, a)))
```
|
instruction
| 0
| 103,056
| 11
| 206,112
|
Yes
|
output
| 1
| 103,056
| 11
| 206,113
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
Submitted Solution:
```
n,m = map(int,input().split())
a=[0]*5001
for i in range(1,5001):
a[i]=(i-1)//2
# print(a[:20])
for i in range(1,5001):
a[i]=a[i]+a[i-1]
# print(a[:20])
ans=[]
if m==0:
# ans.append(1)
aa=1
for i in range(n):
ans.append(aa)
aa=aa+4
print(*ans)
elif m>a[n]:
print(-1)
else:
if m in a:
ind = a.index(m)
for i in range(1,ind+1):
ans.append(i)
else:
for i in range(1,5000):
if a[i]<m<a[i+1]:
for j in range(1,i+1):
ans.append(j)
gap = m-a[i]
# print(gap,i)
ans.append(2*i-2*gap+1)
l=len(ans)
if l<n :
aa = ans[l-1]
x=aa+1
for k in range(n-l):
ans.append(aa+x)
aa = aa+x
print(len(ans))
print(*ans)
```
|
instruction
| 0
| 103,057
| 11
| 206,114
|
No
|
output
| 1
| 103,057
| 11
| 206,115
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
Submitted Solution:
```
dic={}
count=0
for i in range(1,5001):
count+=(i-1)//2
dic[i]=count
n,m=map(int,input().split())
if(m>dic[n]):print(-1)
else:
ls=[]
for i in range(1,5000):
if(dic[i]>m):
break
else:
ls.append(i)
m-=dic[i-1]
while m and ls[-1]+ls[-2]<=10**9:
ls.append(ls[-1]+ls[-2])
m-=1
if(m):ls.append(10**9)
i=1
while m:
ls.append(10**9-i)
i+=1
m-=1
if(len(ls)<=n):
for i in range(n-len(ls)):
ls.append(10**9)
ls.sort()
print(*ls)
else:
print(-1)
```
|
instruction
| 0
| 103,058
| 11
| 206,116
|
No
|
output
| 1
| 103,058
| 11
| 206,117
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
Submitted Solution:
```
from sys import stdin
from bisect import bisect_left as bl
from bisect import bisect_right as br
def input():
return stdin.readline()[:-1]
def intput():
return int(input())
def sinput():
return input().split()
def intsput():
return map(int, sinput())
class RangedList:
def __init__(self, start, stop, val=0):
self.shift = 0 - start
self.start = start
self.stop = stop
self.list = [val] * (stop - start)
def __setitem__(self, key, value):
self.list[key + self.shift] = value
def __getitem__(self, key):
return self.list[key + self.shift]
def __repr__(self):
return str(self.list)
def __iter__(self):
return iter(self.list)
def dprint(*args, **kwargs):
if debugging:
print(*args, **kwargs)
def sigma(x):
return x * (x + 1) // 2
def maxbalance(x):
if x % 2 == 0:
return sigma(x // 2 - 1) * 2
else:
x += 1
return sigma(x // 2 - 1) * 2 - x // 2 + 1
debugging = 1
# Code
n, balance = intsput()
if maxbalance(n) < balance:
print(-1)
exit()
else:
if n <= 2:
print('1 2')
exit()
largest = 2
dist = [1, 2]
k = 1
while len(dist) < n:
if balance:
x = dist[-1] + 1
can_create = (x - 1) // 2
if can_create <= balance:
dist.append(x)
balance -= can_create
largest = x
else:
dist.append(dist[- (balance * 2)] + dist[-1])
balance = 0
#used = set(dist)
else:
dist.append(10 ** 8 + 10 ** 4 * k + 1)
k += 1
print(*dist)
```
|
instruction
| 0
| 103,059
| 11
| 206,118
|
No
|
output
| 1
| 103,059
| 11
| 206,119
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.
The round consists of n problems, numbered from 1 to n. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a_1, a_2, ..., a_n, where a_i is the score of i-th problem.
Kuroni thinks that the score distribution should satisfy the following requirements:
* The score of each problem should be a positive integer not exceeding 10^9.
* A harder problem should grant a strictly higher score than an easier problem. In other words, 1 ≤ a_1 < a_2 < ... < a_n ≤ 10^9.
* The balance of the score distribution, defined as the number of triples (i, j, k) such that 1 ≤ i < j < k ≤ n and a_i + a_j = a_k, should be exactly m.
Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output -1.
Input
The first and single line contains two integers n and m (1 ≤ n ≤ 5000, 0 ≤ m ≤ 10^9) — the number of problems and the required balance.
Output
If there is no solution, print a single integer -1.
Otherwise, print a line containing n integers a_1, a_2, ..., a_n, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.
Examples
Input
5 3
Output
4 5 9 13 18
Input
8 0
Output
10 11 12 13 14 15 16 17
Input
4 10
Output
-1
Note
In the first example, there are 3 triples (i, j, k) that contribute to the balance of the score distribution.
* (1, 2, 3)
* (1, 3, 4)
* (2, 4, 5)
Submitted Solution:
```
def Fib(n):
f = [1,2]
for i in range(3,n+1):
x = f[-1]+f[-2]
f.append(x)
return f
fib = Fib(10001)
# print(fib)
def f():
n, m = [int(s) for s in input().split()]
if m >=n-1:
print(-1)
return
ans = fib[:m+2]
i = m
for j in range(n-(m+2)):
ans.append(fib[i])
i += 2
print(' '.join(str(num) for num in ans))
f()
```
|
instruction
| 0
| 103,060
| 11
| 206,120
|
No
|
output
| 1
| 103,060
| 11
| 206,121
|
Provide tags and a correct Python 3 solution for this coding contest problem.
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Examples
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
|
instruction
| 0
| 103,223
| 11
| 206,446
|
Tags: implementation
Correct Solution:
```
n = int(input())
p = 0
a = []
for _ in range(n):
x, k = list(map(int, input().split()))
while k > len(a):
a.append(-1)
k = k - 1
if a[k] < x - 1:
print('NO')
exit()
else:
a[k] = max(x, a[k])
print('YES')
```
|
output
| 1
| 103,223
| 11
| 206,447
|
Provide tags and a correct Python 3 solution for this coding contest problem.
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Examples
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
|
instruction
| 0
| 103,224
| 11
| 206,448
|
Tags: implementation
Correct Solution:
```
def readln(): return tuple(map(int, input().split()))
n, = readln()
max_pref = [-1] * 100001
flag = True
for _ in range(n):
x, k = readln()
flag &= max_pref[k] + 1 >= x
max_pref[k] = max(max_pref[k], x)
print('YES' if flag else 'NO')
```
|
output
| 1
| 103,224
| 11
| 206,449
|
Provide tags and a correct Python 3 solution for this coding contest problem.
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Examples
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
|
instruction
| 0
| 103,225
| 11
| 206,450
|
Tags: implementation
Correct Solution:
```
c = [0] * 100001
for i in range(int(input())):
x, k = map(int, input().split())
if x == c[k]:
c[k] += 1
elif x > c[k]:
print('NO')
exit()
print('YES')
```
|
output
| 1
| 103,225
| 11
| 206,451
|
Provide tags and a correct Python 3 solution for this coding contest problem.
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Examples
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
|
instruction
| 0
| 103,226
| 11
| 206,452
|
Tags: implementation
Correct Solution:
```
d = [0] * 100001
for _ in range(int(input())):
v, k = map(int, input().split())
if v > d[k]:
print('NO')
exit()
elif v == d[k]:
d[k] += 1
print('YES')
```
|
output
| 1
| 103,226
| 11
| 206,453
|
Provide tags and a correct Python 3 solution for this coding contest problem.
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Examples
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
|
instruction
| 0
| 103,227
| 11
| 206,454
|
Tags: implementation
Correct Solution:
```
n = int(input())
a = [-1]*100001
p = 0
for i in range(n):
x, k = map(int, input().split())
if a[k] < x-1:
p = 1
else:
a[k] = max(a[k],x)
if p:
print('NO')
else:
print('YES')
```
|
output
| 1
| 103,227
| 11
| 206,455
|
Provide tags and a correct Python 3 solution for this coding contest problem.
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Examples
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
|
instruction
| 0
| 103,228
| 11
| 206,456
|
Tags: implementation
Correct Solution:
```
from collections import deque
for _ in range(1):
n = int(input())
visited = set()
flag = 1
for i in range(n):
x,k = map(int,input().split())
if x == 0:
visited.add((x,k))
else:
if (x-1,k) in visited:
visited.add((x, k))
else:
flag = 0
if flag:
print("YES")
else:
print("NO")
```
|
output
| 1
| 103,228
| 11
| 206,457
|
Provide tags and a correct Python 3 solution for this coding contest problem.
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Examples
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
|
instruction
| 0
| 103,229
| 11
| 206,458
|
Tags: implementation
Correct Solution:
```
data = {}
for _ in range(int(input())):
x, k = map(int, input().split())
if k in data:
data[k].append(x)
else:
data[k] = [x]
flag = True
for counts in data.values():
allowed = 0
for count in counts:
if count > allowed:
flag = False
break
if count == allowed:
allowed += 1
if not flag:
break
print(['NO', 'YES'][flag])
```
|
output
| 1
| 103,229
| 11
| 206,459
|
Provide tags and a correct Python 3 solution for this coding contest problem.
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Examples
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
|
instruction
| 0
| 103,230
| 11
| 206,460
|
Tags: implementation
Correct Solution:
```
#the basic idea is to use a dict to record every participant's submission
n = int(input())
participants = {}
order = True
while n:
n -= 1
x, k = map(int,input().split())
if k in participants:
if x in participants[k]:
continue
elif x-1 in participants[k]:
participants[k].add(x)
else:
order = False
break
else:
if x != 0:
order = False
break
tmp = set()
tmp.add(x)
participants[k] = tmp
if order:
print("YES")
else:
print("NO")
```
|
output
| 1
| 103,230
| 11
| 206,461
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Examples
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
Submitted Solution:
```
n = int(input())
m = []
d = dict()
for i in range(n):
x, k = map(int, input().split())
if k in d:
r = d[k]
if x > r+1:
print('NO')
exit()
d[k] = max(r, x)
else:
if x != 0:
print('NO')
exit()
d[k] = x
print('YES')
```
|
instruction
| 0
| 103,231
| 11
| 206,462
|
Yes
|
output
| 1
| 103,231
| 11
| 206,463
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Examples
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
Submitted Solution:
```
sol=int(input())
list1=[]
for i in range(10**5+1):
list1.append([])
for i in range(sol):
a,b=input().split()
b=int(b)
list1[b].append(a)
i=0
v=True
while i<10**5+1 and v:
j=0
z=-1
while j<len(list1[i]) and v:
if (int(list1[i][j])-z)==1:
z=int(list1[i][j])
elif int(list1[i][j])-z>1:
v=False
j+=1
i+=1
if v==True:
print("YES")
else:
print("NO")
```
|
instruction
| 0
| 103,232
| 11
| 206,464
|
Yes
|
output
| 1
| 103,232
| 11
| 206,465
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Examples
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
Submitted Solution:
```
all = {}
n = int(input())
ans = True
for i in range(n):
x_k = input().split()
x = int(x_k[0])
k = int(x_k[1])
if k not in all:
all[k] = -1
if all[k] >= x:
pass
elif all[k]+1 != x:
ans = False
break
else:
all[k] = x
if ans:
print("YES")
else:
print("NO")
```
|
instruction
| 0
| 103,233
| 11
| 206,466
|
Yes
|
output
| 1
| 103,233
| 11
| 206,467
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Examples
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
Submitted Solution:
```
import sys
n = int(input())
c = [-1] * (10**5+1)
for i in range(n):
x,k = map(int,input().split())
if c[k] < x-1:
print("NO")
sys.exit()
else:
c[k] = max(c[k],x)
print("YES")
```
|
instruction
| 0
| 103,234
| 11
| 206,468
|
Yes
|
output
| 1
| 103,234
| 11
| 206,469
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Examples
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
Submitted Solution:
```
n,q,t=int(input()),{},0
for i in range(n):
a,x=map(int,input().split())
if a not in q:q[a]=[x]
else:q[a].append(x)
for i in q:
k=list(q[i])
q[i].sort()
if k!=q[i]:
t=1
break
print(["YES","NO"][t])
```
|
instruction
| 0
| 103,235
| 11
| 206,470
|
No
|
output
| 1
| 103,235
| 11
| 206,471
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Examples
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
Submitted Solution:
```
from collections import OrderedDict
all = {}
n = int(input())
for i in range(n):
x_k = input().split()
x = int(x_k[0])
k = int(x_k[1])
if k not in all:
all[k] = OrderedDict()
all[k][x] = True
# print("new", k, all[k])
else:
all[k][x] = True
# print("old", k, all[k])
def check(dic):
l = []
for x in dic:
l.append(x)
el = l[0]
for i in range(1, len(l)):
if l[i] < el:
return False
else:
el = l[i]
continue
return True
ans = True
for x in all:
if check(all[x]):
continue
else:
ans = False
if ans:
print("YES")
else:
print("NO")
```
|
instruction
| 0
| 103,236
| 11
| 206,472
|
No
|
output
| 1
| 103,236
| 11
| 206,473
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.