message
stringlengths
2
39.6k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
219
108k
cluster
float64
11
11
__index_level_0__
int64
438
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero. Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating. What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible". Input The first line of the input contains a single integer n (1 ≤ n ≤ 200 000). The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest. Output If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests. Examples Input 3 -7 1 5 2 8 2 Output 1907 Input 2 57 1 22 2 Output Impossible Input 1 -5 1 Output Infinity Input 4 27 2 13 1 -50 1 8 2 Output 1897 Note In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating: * Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7. * With rating 1894 Limak is in the division 2. His rating increases by 5. * Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907. In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest.
instruction
0
63,583
11
127,166
Tags: binary search, greedy, math Correct Solution: ``` q=int(input()) q-=1 a,s=map(int,input().split()) if s==1: z=1900 x=9000000000 else: z=-9000000000 x=1899 z+=a x+=a for j in range(0,q): a,s=map(int,input().split()) if s==1: z=max(1900,z) else: x=min(1899,x) z+=a x+=a if x<z: print('Impossible') elif x>=7000000000: print('Infinity') else: print(x) ```
output
1
63,583
11
127,167
Provide tags and a correct Python 3 solution for this coding contest problem. Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero. Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating. What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible". Input The first line of the input contains a single integer n (1 ≤ n ≤ 200 000). The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest. Output If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests. Examples Input 3 -7 1 5 2 8 2 Output 1907 Input 2 57 1 22 2 Output Impossible Input 1 -5 1 Output Infinity Input 4 27 2 13 1 -50 1 8 2 Output 1897 Note In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating: * Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7. * With rating 1894 Limak is in the division 2. His rating increases by 5. * Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907. In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest.
instruction
0
63,584
11
127,168
Tags: binary search, greedy, math Correct Solution: ``` n=int(input()) INF=10**18 l=-INF r=INF s=0 for _ in range(n): c,d=map(int,input().split()) if d==1 and l+s<1900: l=1900-s if d==2 and r+s>=1900: r=1899-s s+=c if l<-INF: l=-INF if r>INF: r=INF if l>r: print("Impossible") elif r>10**15: print("Infinity") else: print(r+s) ```
output
1
63,584
11
127,169
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero. Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating. What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible". Input The first line of the input contains a single integer n (1 ≤ n ≤ 200 000). The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest. Output If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests. Examples Input 3 -7 1 5 2 8 2 Output 1907 Input 2 57 1 22 2 Output Impossible Input 1 -5 1 Output Infinity Input 4 27 2 13 1 -50 1 8 2 Output 1897 Note In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating: * Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7. * With rating 1894 Limak is in the division 2. His rating increases by 5. * Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907. In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest. Submitted Solution: ``` n = int(input()) A = [0] * n per = 0 ans1 = float('infinity') ans2 = -float('infinity') for j in range(n): per1,per2 = map(int,input().split()) if per2 == 1: if ans1 < 1900: per = 1 break else: ans2 = max(ans2,1900) ans1 += per1 ans2 += per1 else: if ans2 >= 1900: per =1 break else: ans1 = min(ans1,1899) ans1 += per1 ans2 += per1 if ans1 < ans2: per = 1 break if per == 0: if ans1 == float('infinity'): print('Infinity') else: print(ans1) else: print('Impossible') ```
instruction
0
63,585
11
127,170
Yes
output
1
63,585
11
127,171
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero. Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating. What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible". Input The first line of the input contains a single integer n (1 ≤ n ≤ 200 000). The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest. Output If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests. Examples Input 3 -7 1 5 2 8 2 Output 1907 Input 2 57 1 22 2 Output Impossible Input 1 -5 1 Output Infinity Input 4 27 2 13 1 -50 1 8 2 Output 1897 Note In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating: * Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7. * With rating 1894 Limak is in the division 2. His rating increases by 5. * Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907. In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest. Submitted Solution: ``` n = int(input()) c, d = map(int, input().split()) min_ = 0 max_ = 0 flag = True if d == 1: min_ = 1900 max_ = float("+Inf") else: min_ = float("-Inf") max_ = 1899 for i in range(n - 1): c1, d = map(int, input().split()) if d == 1: min_ = max(min_ + c, 1900) max_ += c else: max_ = min(max_ + c, 1899) min_ += c if min_ > max_: flag = False c = c1 min_ += c max_ += c if not(flag): print("Impossible") elif max_ == float("+Inf"): print("Infinity") else: print(max_) ```
instruction
0
63,586
11
127,172
Yes
output
1
63,586
11
127,173
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero. Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating. What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible". Input The first line of the input contains a single integer n (1 ≤ n ≤ 200 000). The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest. Output If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests. Examples Input 3 -7 1 5 2 8 2 Output 1907 Input 2 57 1 22 2 Output Impossible Input 1 -5 1 Output Infinity Input 4 27 2 13 1 -50 1 8 2 Output 1897 Note In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating: * Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7. * With rating 1894 Limak is in the division 2. His rating increases by 5. * Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907. In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest. Submitted Solution: ``` n = int(input()) up = -10 ** 9 down = -up for i in range(n): c, d = map(int, input().split()) if d == 1: up = max(1900, up) else: down = min(1899, down) up += c down += c if down < up: print('Impossible') elif down >= 10 ** 8: print('Infinity') else: print(down) ```
instruction
0
63,587
11
127,174
Yes
output
1
63,587
11
127,175
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero. Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating. What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible". Input The first line of the input contains a single integer n (1 ≤ n ≤ 200 000). The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest. Output If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests. Examples Input 3 -7 1 5 2 8 2 Output 1907 Input 2 57 1 22 2 Output Impossible Input 1 -5 1 Output Infinity Input 4 27 2 13 1 -50 1 8 2 Output 1897 Note In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating: * Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7. * With rating 1894 Limak is in the division 2. His rating increases by 5. * Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907. In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest. Submitted Solution: ``` """ Author : Arif Ahmad Date : Algo : Difficulty : """ def main(): n = int(input()) mn = -int(2e9) mx = int(2e9) impossible = False for i in range(n): c, d = [int(_) for _ in input().split()] if (d==1 and mx<1900) or (d==2 and mn>1899): impossible = True break if d == 1: mn = max(mn, 1900) else: mx = min(mx, 1899) mn += c mx += c if mn > mx: impossible = True break if impossible: print('Impossible') elif mx > 1e9: print('Infinity') else: print(mx) if __name__ == '__main__': main() ```
instruction
0
63,588
11
127,176
Yes
output
1
63,588
11
127,177
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero. Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating. What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible". Input The first line of the input contains a single integer n (1 ≤ n ≤ 200 000). The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest. Output If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests. Examples Input 3 -7 1 5 2 8 2 Output 1907 Input 2 57 1 22 2 Output Impossible Input 1 -5 1 Output Infinity Input 4 27 2 13 1 -50 1 8 2 Output 1897 Note In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating: * Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7. * With rating 1894 Limak is in the division 2. His rating increases by 5. * Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907. In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest. Submitted Solution: ``` n=int(input()) d=[] r=[] s=[i for i in range(1900)] s.reverse() for i in range(n): a,b=map(int,input().split()) r.append(a) d.append(b) try: try: x = d[d.index(2)+1:].index(1)+d.index(2) except: x=n-1 p = False while p == False: q = s[0] p = True for i in range(x + 1, n): q += r[i - 1] if d[i] == 1: if q < 1900: s.pop(0) p = False break else: if q > 1899: s.pop(0) p = False break res=q +r[-1] if s[0] == 0: print('Impossible') break if not p: continue q = s[0] for i in range(1, x + 1): q -= r[x - i] if d[x - i] == 1: if q < 1900: s.pop(0) p = False break else: if q > 1899: s.pop(0) p = False break else: print(res) except ValueError: print('Infinity') ```
instruction
0
63,589
11
127,178
No
output
1
63,589
11
127,179
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero. Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating. What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible". Input The first line of the input contains a single integer n (1 ≤ n ≤ 200 000). The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest. Output If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests. Examples Input 3 -7 1 5 2 8 2 Output 1907 Input 2 57 1 22 2 Output Impossible Input 1 -5 1 Output Infinity Input 4 27 2 13 1 -50 1 8 2 Output 1897 Note In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating: * Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7. * With rating 1894 Limak is in the division 2. His rating increases by 5. * Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907. In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest. Submitted Solution: ``` from sys import stdin, stdout n = int(stdin.readline()) questions = [] label = 0 for i in range(n): value, d = map(int, stdin.readline().split()) questions.append((value, d)) r = 1899 label = 0 if questions[0][1] == 2: ind = 0 cnt = 0 for i in range(n): if questions[i][1] == 2: cnt += questions[i][0] else: break l = 1900 - cnt r = 1900 + questions[i - 1][0] - cnt else: for i in range(n): if questions[i][1] == 2: l = 1900 + questions[i - 1][0] ind = i break else: label = 1 if label: stdout.write('Infinity') else: for i in range(r, l - 1, -1): rating = i for j in range(ind, n): if questions[j][1] == 1 and rating < 1900: break elif questions[j][1] == 2 and rating >= 1900: break rating += questions[j][0] else: stdout.write(str(rating)) break else: stdout.write('Impossible') ```
instruction
0
63,590
11
127,180
No
output
1
63,590
11
127,181
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero. Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating. What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible". Input The first line of the input contains a single integer n (1 ≤ n ≤ 200 000). The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest. Output If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests. Examples Input 3 -7 1 5 2 8 2 Output 1907 Input 2 57 1 22 2 Output Impossible Input 1 -5 1 Output Infinity Input 4 27 2 13 1 -50 1 8 2 Output 1897 Note In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating: * Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7. * With rating 1894 Limak is in the division 2. His rating increases by 5. * Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907. In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest. Submitted Solution: ``` n = int(input()) rounds = [[*map(int, input().split())] for _ in range(n)] if all(i[1] == 1 for i in rounds): print('Infinity') elif any((rounds[i][0] >= 0 and rounds[i][1] == 1 and rounds[i + 1][1] == 2) or \ (rounds[i][0] < 0 and rounds[i][1] == 2 and rounds[i + 1][1] == 1) for i in range(n - 1)): print('Impossible') else: l = int(-2e7) r = int(2e7) def check(m): d = 1 if m >= 1900 else 2 for i, j in rounds[::-1]: m += -i d = 1 if m >= 1900 else 2 if d == 1 and j == 2: return False, -1 return True, m t = -1 while r - l > 1: m = (l + r) // 2 c, t1 = check(m) t = t1 if t1 != -1 else t if c: l = m else: r = m d = 1 if t >= 1900 else 2 if rounds[:2] == [[1, 2], [100, 1]]: print(rounds[-10:]) for i, j in rounds: if d != j: print('Impossible') exit() t += i d = 1 if t >= 1900 else 2 print(l) ```
instruction
0
63,591
11
127,182
No
output
1
63,591
11
127,183
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower belong to the second division. In every contest, according to one's performance, his or her rating changes by some value, possibly negative or zero. Limak competed in n contests in the year 2016. He remembers that in the i-th contest he competed in the division di (i.e. he belonged to this division just before the start of this contest) and his rating changed by ci just after the contest. Note that negative ci denotes the loss of rating. What is the maximum possible rating Limak can have right now, after all n contests? If his rating may be arbitrarily big, print "Infinity". If there is no scenario matching the given information, print "Impossible". Input The first line of the input contains a single integer n (1 ≤ n ≤ 200 000). The i-th of next n lines contains two integers ci and di ( - 100 ≤ ci ≤ 100, 1 ≤ di ≤ 2), describing Limak's rating change after the i-th contest and his division during the i-th contest contest. Output If Limak's current rating can be arbitrarily big, print "Infinity" (without quotes). If the situation is impossible, print "Impossible" (without quotes). Otherwise print one integer, denoting the maximum possible value of Limak's current rating, i.e. rating after the n contests. Examples Input 3 -7 1 5 2 8 2 Output 1907 Input 2 57 1 22 2 Output Impossible Input 1 -5 1 Output Infinity Input 4 27 2 13 1 -50 1 8 2 Output 1897 Note In the first sample, the following scenario matches all information Limak remembers and has maximum possible final rating: * Limak has rating 1901 and belongs to the division 1 in the first contest. His rating decreases by 7. * With rating 1894 Limak is in the division 2. His rating increases by 5. * Limak has rating 1899 and is still in the division 2. In the last contest of the year he gets + 8 and ends the year with rating 1907. In the second sample, it's impossible that Limak is in the division 1, his rating increases by 57 and after that Limak is in the division 2 in the second contest. Submitted Solution: ``` n=int(input()) mx=5*(10**9) mn=-10**9 flag = True for i in range(n): c,d=map(int,input().split()) if d==1: mn=max(mn,1900) else: mx=min(mx,1899) if mn>mx: flag=False #besi poriman barar poro div_2 othoba besi komar poro jodi div_1 dekhay mn+=c;mx+=c if not flag:print("impossible") else: if mx>10**9:print("Infinity") #'mx' er sathe je kono number jog biog er poro jeno sothik condition break na kore else:print(mx) #'d==2' kokhono na thakle 'infinity' ```
instruction
0
63,592
11
127,184
No
output
1
63,592
11
127,185
Provide tags and a correct Python 3 solution for this coding contest problem. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
instruction
0
63,672
11
127,344
Tags: binary search, brute force, data structures, greedy, sortings Correct Solution: ``` from collections import deque import heapq import sys def input(): return sys.stdin.readline().rstrip() n, T = map(int, input().split()) problems = [tuple(map(int, input().split())) for i in range(n)] def possible(K): d = [] for a, t in problems: if a >= K: d.append(t) d.sort() if len(d) < K: return False else: return sum(d[:K]) <= T l = 0 r = n + 1 while r - l > 1: med = (r + l)//2 if possible(med): l = med else: r = med print(l) print(l) d = [] for i, (a, t) in enumerate(problems): if a >= l: d.append((t, i+1)) d.sort(key=lambda x: x[0]) ans = [v[1] for v in d[:l]] print(*ans) ```
output
1
63,672
11
127,345
Provide tags and a correct Python 3 solution for this coding contest problem. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
instruction
0
63,673
11
127,346
Tags: binary search, brute force, data structures, greedy, sortings Correct Solution: ``` import os import collections def ints(): bytes = bytearray() while True: buffer = os.read(0, 1024) if len(buffer) == 0: break bytes.extend(buffer) array = collections.deque(map(int, bytes.split())) return array def one_pass(pass_num): global ans_k, ans_b b_time = b_count = 0 c_time = [0] * (n + 1) c_count = [0] * (n + 1) k = 1 for i in a: if b_count < k: if value(i) >= k: b_count += 1 b_time += time(i) c_count[value(i)] += 1 c_time [value(i)] += time(i) if pass_num == 2 and ans_k and value(i) >= ans_k: ans_b.append(index(i)) if b_count == k: if pass_num == 1 and b_time <= T: ans_k = k if pass_num == 2 and k == ans_k: break b_count -= c_count[k] b_time -= c_time[k] k += 1 v = ints() n, T = v.popleft(), v.popleft() a = [] for i in range(n): k, t = v.popleft(), v.popleft() a.append( (i+1, k, t) ) index = lambda x: x[0] value = lambda x: x[1] time = lambda x: x[2] a.sort(key=time) ans_k = 0 ans_b = [] one_pass(1) one_pass(2) print(ans_k) print(ans_k) print(" ".join(map(str, ans_b))) ```
output
1
63,673
11
127,347
Provide tags and a correct Python 3 solution for this coding contest problem. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
instruction
0
63,674
11
127,348
Tags: binary search, brute force, data structures, greedy, sortings Correct Solution: ``` import sys import math from collections import defaultdict,deque import heapq def search(arr,points,t): l=[] n=len(arr) cnt=0 for i in range(n): if arr[i][0]>=points: l.append(arr[i][1]) cnt+=1 if cnt>=points: l.sort() #print(l,'l') if sum(l[:points])<=t: return True return False def get(arr,points): n=len(arr) l=[] for i in range(n): if arr[i][0]>=points: l.append([arr[i][1],arr[i][2]+1]) l.sort() #print(l,'get') res=[] for i in range(points): res.append(l[i][1]) return res n,t=map(int,sys.stdin.readline().split()) dic=defaultdict(int) arr=[] for i in range(n): a,b=map(int,sys.stdin.readline().split()) arr.append([a,b,i]) low,high=0,n ans=0 while low<=high: mid=(low+high)//2 if search(arr,mid,t): ans=max(ans,mid) low=mid+1 else: high=mid-1 #print(ans) if ans==0: print(0) print(0) print('') sys.exit() l=get(arr,ans) print(len(l)) print(len(l)) print(*l) ```
output
1
63,674
11
127,349
Provide tags and a correct Python 3 solution for this coding contest problem. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
instruction
0
63,675
11
127,350
Tags: binary search, brute force, data structures, greedy, sortings Correct Solution: ``` # -*- coding: utf-8 -*- """ Created on Fri Jan 12 18:46:09 2018 @author: Sand Boa """ import itertools if __name__ == "__main__": n:int T:int n, T = list(map(int,input().split())) listi:list = [] tsum:int = 0 csum:int = 0 k:int k = 1 a:int b:int t:int ind:int for i in range(n): a,b = list(map(int,input().split())) listi.append((a,b,i)) #print(listi) listi = sorted(listi, key=lambda x: x[1]) #print(listi) time:list = [0] * (n + 1) count:list = [0] * (n + 1) for (a, t, ind) in listi: if k <= a: tsum += t time[a] += t if tsum > T: break count[a] += 1 csum += 1 if csum == k: csum -= count[k] tsum -= time[k] k += 1 max_score:int = max(csum, k - 1) print (max_score,max_score,sep='\n') print(*list(itertools.islice((idx + 1 for (a, t, idx) in listi if a >= max_score),max_score))) ```
output
1
63,675
11
127,351
Provide tags and a correct Python 3 solution for this coding contest problem. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
instruction
0
63,676
11
127,352
Tags: binary search, brute force, data structures, greedy, sortings Correct Solution: ``` # -*- coding: utf-8 -*- """ Created on Fri Jan 12 18:46:09 2018 @author: Sand Boa """ import itertools if __name__ == "__main__": n:int T:int n, T = list(map(int,input().split())) listi:list = [] tsum:int = 0 csum:int = 0 k = 1 a:int b:int for i in range(n): a,b = list(map(int,input().split())) listi.append((a,b,i)) #print(listi) listi = sorted(listi, key=lambda x: x[1]) #print(listi) time:list = [0] * (n + 1) count:list = [0] * (n + 1) for (a, t, ind) in listi: if k <= a: tsum += t time[a] += t if tsum > T: break count[a] += 1 csum += 1 if csum == k: csum -= count[k] tsum -= time[k] k += 1 max_score = max(csum, k - 1) print (max_score,max_score,sep='\n') print(*list(itertools.islice( (idx + 1 for (a, t, idx) in listi if a >= max_score), max_score ))) #print(listi) '''for a, t, idx in listi: if idx > max_score: print(idx,sep=" ") ''' #print(idx+1 for in listi ) ```
output
1
63,676
11
127,353
Provide tags and a correct Python 3 solution for this coding contest problem. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
instruction
0
63,677
11
127,354
Tags: binary search, brute force, data structures, greedy, sortings Correct Solution: ``` import sys input=sys.stdin.readline def fun(k): global li,t tem=[] count=0 for i in li: if(i[0]>=k): tem.append(i) count+=1 if(count>=k): ans=0 for i in range(k): ans+=tem[i][1] if(ans<=t): return True else: return False else: return False n,t=map(int,input().split()) li=[] for _ in range(n): li.append(list(map(int,input().split()))+[_]) li.sort(key=lambda x:x[1]) l=0 r=n while(r-l>1): mid=(l+r)//2 if(fun(mid)): l=mid else: r=mid fin=0 for i in range(l,r+1): if(fun(i)): fin=i print(fin) print(fin) tem=[] for i in range(n): if(li[i][0]>=fin): tem.append(li[i][2]+1) print(*tem[:fin]) ```
output
1
63,677
11
127,355
Provide tags and a correct Python 3 solution for this coding contest problem. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
instruction
0
63,678
11
127,356
Tags: binary search, brute force, data structures, greedy, sortings Correct Solution: ``` # https://codeforces.com/contest/913/problem/D import heapq from heapq import heappush as push_ from heapq import heappop as pop_ class heapT(): def __init__(self, T): self.Q = [] self.curT = 0 self.maxT = T self.his = [] def push(self, t, index): push_(self.Q, (-t, index)) self.his.append(index) self.curT += t while self.curT > self.maxT: self.pop() def pop(self): t, ind = pop_(self.Q) self.his.append(ind) self.curT -= t * -1 def normalize(self, length): while len(self.Q) > length: self.pop() def solve(a, n, T): a = sorted(a, key=lambda x:x[0], reverse=True) H = heapT(T) max_ = -1 pos = None for ak, t, ind in a: H.push(t, ind) H.normalize(ak) if len(H.Q) > max_: max_ = len(H.Q) pos = len(H.his) d = {} if pos is not None: for x in H.his[:pos]: if x not in d: d[x] = 1 else: del d[x] if len(d) > 0: print(len(d)) print(len(d)) print(' '.join([str(x+1) for x in d])) else: print('0'+'\n'+'0') n, T = map(int, input().split()) a = [list(map(int, input().split())) + [_] for _ in range(n)] solve(a, n, T) #5 300 #3 100 #4 150 #4 80 #2 90 #2 300 #7 100 #5 30 #5 40 #6 20 #2 50 #2 40 #3 10 #4 10 #2 100 #1 787 #2 788 ```
output
1
63,678
11
127,357
Provide tags and a correct Python 3 solution for this coding contest problem. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.
instruction
0
63,679
11
127,358
Tags: binary search, brute force, data structures, greedy, sortings Correct Solution: ``` # -*- coding: utf-8 -*- """ Created on Fri Jan 12 18:46:09 2018 @author: Sand Boa """ import sys import operator # itemgetter import itertools # islice if __name__ == "__main__": n, T = list(map(int,input().split())) listi = [] for i in range(n): a,b = list(map(int,input().split())) listi.append((a,b,i)) #print(listi) listi = sorted(listi, key=lambda x: x[1]) #print(listi) time = [0] * (n + 1) count = [0] * (n + 1) time_sum = 0 count_sum = 0 k = 1 for (a, t, ind) in listi: if k <= a: time[a] += t time_sum += t if time_sum > T: break count[a] += 1 count_sum += 1 if count_sum == k: count_sum -= count[k] time_sum -= time[k] k += 1 max_score = max(count_sum, k - 1) #max_score = count_sum print (max_score) print (max_score) print(*list(itertools.islice( (idx + 1 for (a, t, idx) in listi if a >= max_score), max_score ))) #print(listi) '''for a, t, idx in listi: if idx > max_score: print(idx,sep=" ") ''' #print(idx+1 for in listi ) ```
output
1
63,679
11
127,359
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile. Submitted Solution: ``` # -*- coding:utf-8 -*- """ created by shuangquan.huang at 1/11/18 """ import math import collections import bisect import heapq import time import random import itertools import sys N, T = map(int, input().split()) # # N, T = 200000, 1000000000 ta = [] for i in range(N): a, t = map(int, input().split()) ta.append((t, a, i+1)) # ta.append((10000, 200000, i+1)) ta.sort() score = 0 solvedCount = 0 aks = [] heapq.heapify(aks) sc = collections.defaultdict(list) for i in range(N): t, a, _ = ta[i] if T < t: break T -= t solvedCount += 1 sc[a].append((t, i)) heapq.heappush(aks, a) removed = [] while aks and aks[0] < solvedCount: k = heapq.heappop(aks) removed.append(k) v = sc[k] solvedCount -= len(v) for _, j in v: T += ta[j][0] del sc[k] score = max(score, solvedCount) print(score) print(score) vta = [(t, a, i) for t, a, i in ta if a >= score] vta.sort() ans = [i for _, _, i in vta[:score]] print(" ".join(map(str, ans))) ```
instruction
0
63,680
11
127,360
Yes
output
1
63,680
11
127,361
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile. Submitted Solution: ``` import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") n, k = map(int, input().split()) b = [] d=dict() e=dict() for i in range(n): a, t = map(int, input().split()) b.append([a,t,i+1]) b.sort(key= lambda x:x[1]) ans = 0 j = 0 curr = 1 currsum = 0 l=0 while(curr<=n): if curr-1 in d.keys(): currsum-=d[curr-1] l-=e[curr-1] p=0 while (j < n): if b[j][0] >= curr: currsum += b[j][1] if b[j][0] in d.keys(): d[b[j][0]]+=b[j][1] e[b[j][0]]+=1 else: d[b[j][0]] = b[j][1] e[b[j][0]] = 1 l+=1 if l==curr: j+=1 break j+=1 if j<=n and l==curr and currsum<=k: ans+=1 else: break curr+=1 c=[] j=0 l=0 while(j<n): if l==ans: break if b[j][0] >= ans: c.append(b[j][2]) l+=1 j+=1 print(ans) print(ans) print(*c) ```
instruction
0
63,681
11
127,362
Yes
output
1
63,681
11
127,363
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile. Submitted Solution: ``` from __future__ import print_function # for PyPy2 from collections import Counter, OrderedDict from itertools import permutations as perm from collections import deque from sys import stdin from bisect import * from heapq import * import math g = lambda : stdin.readline().strip() gl = lambda : g().split() gil = lambda : [int(var) for var in gl()] gfl = lambda : [float(var) for var in gl()] gcl = lambda : list(g()) gbs = lambda : [int(var) for var in g()] mod = int(1e9)+7 inf = float("inf") n, t = gil() a = [] for i in range(n): b = gil();b.append(i) a.append(b) a.sort(key=lambda x : (x[1], -x[0])) # print(a) h = [] ct = 0 for ai, ti, i in a: if ct + ti > t: break elif len(h) > ai: continue ct += ti heappush(h, (ai, -ti, i)) while h and h[0][0] < len(h): ai, ti, i = heappop(h) ct += ti print(len(h)) print(len(h)) for _, _, i in h: print(i+1, end=" ") ```
instruction
0
63,682
11
127,364
Yes
output
1
63,682
11
127,365
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile. Submitted Solution: ``` from bisect import bisect_left as bl from bisect import bisect_right as br import heapq import math from collections import * from functools import reduce,cmp_to_key import sys input = sys.stdin.readline # M = mod = 998244353 def factors(n):return sorted(list(set(reduce(list.__add__,([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))) # def inv_mod(n):return pow(n, mod - 2, mod) def li():return [int(i) for i in input().rstrip('\n').split(' ')] def st():return input().rstrip('\n') def val():return int(input().rstrip('\n')) def li2():return [i for i in input().rstrip('\n').split(' ')] def li3():return [int(i) for i in input().rstrip('\n')] n,L = li() l = [] for i in range(n): l.append(li()) index = defaultdict(list) for ind,i in enumerate(l): index[tuple(i)].append(ind + 1) l.sort(key = lambda x:x[1]) d = defaultdict(list) ans = i = tot = currpoints = 0 anspattern = [] he = [] while i < n: if l[i][1] + tot <= L: tot += l[i][1] heapq.heappush(d[l[i][0]],l[i][1]) currpoints += 1 if len(d[l[i][0]]) == 1: heapq.heappush(he,l[i][0]) while len(he) and currpoints > he[0]: temp = heapq.heappop(he) tot -= heapq.heappop(d[temp]) currpoints -= 1 if len(d[temp]):heapq.heappush(he,temp) if currpoints > ans: ans = currpoints i += 1 i = tot = currpoints = 0 he = [] d = defaultdict(list) while i < n: if l[i][1] + tot <= L: tot += l[i][1] heapq.heappush(d[l[i][0]],l[i][1]) currpoints += 1 if len(d[l[i][0]]) == 1: heapq.heappush(he,l[i][0]) while len(he) and currpoints > he[0]: temp = heapq.heappop(he) tot -= heapq.heappop(d[temp]) currpoints -= 1 if len(d[temp]):heapq.heappush(he,temp) if currpoints == ans: anspattern = [] for i in he: for j in d[i]: anspattern.append(index[tuple([i,j])][-1]) index[tuple([i,j])].pop() print(ans) print(len(anspattern)) print(*sorted(anspattern)) exit() i += 1 ```
instruction
0
63,683
11
127,366
Yes
output
1
63,683
11
127,367
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile. Submitted Solution: ``` print(2) print(2) print(3,1) ```
instruction
0
63,684
11
127,368
No
output
1
63,684
11
127,369
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile. Submitted Solution: ``` class Prob: idx, a, t = 0, 0, 0 def __init__(self, idx, a , t): self.idx, self.a, self.t = idx, a, t n, T = map(int, input().split()) probs = [] for i in range(n): a, t = map(int, input().split()) probs.append(Prob(i+1, a, t)) probs.sort(key=lambda x: x.t) s, e = 0, n while s < e: m = (s + e) // 2 cnt, sumT = 0, 0 for x in probs: if x.a >= m and sumT + x.t <= T: cnt += 1 sumT += x.t if cnt > m: s = m + 1 else: e = m cnt, sumT = 0, 0 for x in probs: if x.a >= e and sumT + x.t <= T: cnt += 1 sumT += x.t print(cnt) print(cnt) for x in probs: if x.a >= e and sumT + x.t <= T: print(x.idx, end=' ') ```
instruction
0
63,685
11
127,370
No
output
1
63,685
11
127,371
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile. Submitted Solution: ``` # -*- coding: utf-8 -*- """ Created on Fri Jan 12 18:46:09 2018 @author: Sand Boa """ if __name__ == "__main__": n:int T:int n, T = list(map(int,input().split())) listi:list = [] tsum:int = 0 csum:int = 0 k = 1 a:int b:int for i in range(n): a,b = list(map(int,input().split())) listi.append((a,b,i)) #print(listi) listi = sorted(listi, key=lambda x: x[1]) #print(listi) time:list = [0] * (n + 1) count:list = [0] * (n + 1) for (a, t, ind) in listi: if k <= a: tsum += t time[a] += t if tsum > T: break count[a] += 1 csum += 1 if csum == k: csum -= count[k] tsum -= time[k] k += 1 max_score = max(csum, k - 1) print (max_score,max_score,sep='\n') for (a, t, idx) in listi[:max_score+1]: if idx > max_score: print(idx,end=" ") ```
instruction
0
63,686
11
127,372
No
output
1
63,686
11
127,373
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i). Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of j between 1 and k such that k ≤ apj. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. Input The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n. Output In the first line, output a single integer s — your maximum possible final score. In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve. In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Examples Input 5 300 3 100 4 150 4 80 2 90 2 300 Output 2 3 3 1 4 Input 2 100 1 787 2 788 Output 0 0 Input 2 100 2 42 2 58 Output 2 2 1 2 Note In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points. In the second example, the length of the exam is catastrophically not enough to solve even a single problem. In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile. Submitted Solution: ``` # -*- coding:utf-8 -*- """ created by shuangquan.huang at 1/11/18 """ import math import collections import bisect import heapq import time import random import itertools import sys N, T = map(int, input().split()) # # N, T = 200000, 1000000000 ta = [] for i in range(N): a, t = map(int, input().split()) ta.append((t, a, i+1)) # ta.append((200000, 10000, i+1)) ta.sort() solvedCount = 0 minsc = float('inf') sc = collections.defaultdict(list) for i in range(N): t, a, _ = ta[i] if T < t: break T -= t solvedCount += 1 sc[a].append((t, i)) minsc = min(minsc, a) if minsc < solvedCount: solvedCount -= len(sc[minsc]) for _, j in sc[minsc]: T += ta[j][0] del sc[minsc] minsc = min(sc.keys()) print(solvedCount) print(solvedCount) solved = [] for tis in sc.values(): solved.extend([ti[1]+1 for ti in tis]) print(' '.join(map(str, solved))) ```
instruction
0
63,687
11
127,374
No
output
1
63,687
11
127,375
Provide a correct Python 3 solution for this coding contest problem. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2
instruction
0
63,736
11
127,472
"Correct Solution: ``` x = int(input()) a = x // 200 print(10 - a) ```
output
1
63,736
11
127,473
Provide a correct Python 3 solution for this coding contest problem. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2
instruction
0
63,737
11
127,474
"Correct Solution: ``` X = int(input()) X = 2000 - (X+1) X //= 200 print(X + 1) ```
output
1
63,737
11
127,475
Provide a correct Python 3 solution for this coding contest problem. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2
instruction
0
63,738
11
127,476
"Correct Solution: ``` X=int(input()) kyu= 10 - X//200 print(kyu) ```
output
1
63,738
11
127,477
Provide a correct Python 3 solution for this coding contest problem. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2
instruction
0
63,739
11
127,478
"Correct Solution: ``` rating = int(input()) print(10 - rating // 200) ```
output
1
63,739
11
127,479
Provide a correct Python 3 solution for this coding contest problem. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2
instruction
0
63,740
11
127,480
"Correct Solution: ``` s = int(input()) print(10 - s//200) ```
output
1
63,740
11
127,481
Provide a correct Python 3 solution for this coding contest problem. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2
instruction
0
63,741
11
127,482
"Correct Solution: ``` XX = int(input()) Kyu = 10-int(XX/200) print(Kyu) ```
output
1
63,741
11
127,483
Provide a correct Python 3 solution for this coding contest problem. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2
instruction
0
63,742
11
127,484
"Correct Solution: ``` n=(int(input())-400)//200 print(8-n) ```
output
1
63,742
11
127,485
Provide a correct Python 3 solution for this coding contest problem. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2
instruction
0
63,743
11
127,486
"Correct Solution: ``` # 入力 X = int(input()) print(10 - X // 200 ) ```
output
1
63,743
11
127,487
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2 Submitted Solution: ``` X = int(input()) print(10 - X // 200) ```
instruction
0
63,744
11
127,488
Yes
output
1
63,744
11
127,489
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2 Submitted Solution: ``` X = int(input()) ans = 2000-X ans = -(-ans//200) print(ans) ```
instruction
0
63,745
11
127,490
Yes
output
1
63,745
11
127,491
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2 Submitted Solution: ``` X = int(input()) print((2199-X)//200) ```
instruction
0
63,746
11
127,492
Yes
output
1
63,746
11
127,493
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2 Submitted Solution: ``` X = int(input()) y = X//200 print(10-y) ```
instruction
0
63,747
11
127,494
Yes
output
1
63,747
11
127,495
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2 Submitted Solution: ``` A, B, C = map(int, input().split()) K= int(input()) if (B**K>A)&(C>B): print("Yes") elif (B**(K-1)>A)&(C>B**1) : print("Yes") elif (B**(K-2)>A)&(C>B**2) : print("Yes") elif (B**(K-3)>A)&(C>B**3) : print("Yes") elif (B**(K-4)>A)&(C>B**4) : print("Yes") elif (B**(K-5)>A)&(C>B**5) : print("Yes") elif (B**(K-6)>A)&(C>B**6) : print("Yes") elif (B**(K-7)>A)&(C>B**7) : print("Yes") else : print("No") ```
instruction
0
63,748
11
127,496
No
output
1
63,748
11
127,497
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2 Submitted Solution: ``` N, K = map(int, input().split()) A = input("").split(" ") A = [int(i) for i in A] for i in range(1, N-K+1): score = 1 p_score = 1 for j in range(i, i+K): score = score * A[j] p_score = p_score * A[j-1] if score > p_score: print("Yes") else: print("No") ```
instruction
0
63,749
11
127,498
No
output
1
63,749
11
127,499
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2 Submitted Solution: ``` A,B,C = map(int,input().split()) K = int(input()) for i in range(K): if C<=B: C*=2 elif B<A and C>B: B*=2 if B>A and C>B: print("Yes") else: print("No") ```
instruction
0
63,750
11
127,500
No
output
1
63,750
11
127,501
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? Constraints * 400 \leq X \leq 1999 * X is an integer. Input Input is given from Standard Input in the following format: X Output Print the kyu M-kun has, as an integer. For example, if he has 8-kyu, print `8`. Examples Input 725 Output 7 Input 1600 Output 2 Submitted Solution: ``` x = int(input()) if x >= 1800: ans = 1 elif x >= 1600: ans = 2 elif x >= 1400: ans = 3 elif x >= 1200: ans = 4 elif x >= 1000: ans = 5 elif x >= 800: ans = 6 elif x >= 600: ans = 7 else: x = 8 print(str(int(ans))) ```
instruction
0
63,751
11
127,502
No
output
1
63,751
11
127,503
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Constraints * 1 \leq N,K \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Examples Input 7 3 Output 1 Input 100 10 Output 0 Input 1 1 Output 0 Submitted Solution: ``` n,k=map(int,input().split()) print((n%k+99)//100) ```
instruction
0
63,824
11
127,648
Yes
output
1
63,824
11
127,649
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Constraints * 1 \leq N,K \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Examples Input 7 3 Output 1 Input 100 10 Output 0 Input 1 1 Output 0 Submitted Solution: ``` n,k=map(int, input().split()) print(1 if n%k!=0 else 0) ```
instruction
0
63,825
11
127,650
Yes
output
1
63,825
11
127,651
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Constraints * 1 \leq N,K \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Examples Input 7 3 Output 1 Input 100 10 Output 0 Input 1 1 Output 0 Submitted Solution: ``` n,k = map(int, input().split()) print(n%k if n%k==0 else 1) ```
instruction
0
63,826
11
127,652
Yes
output
1
63,826
11
127,653
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Constraints * 1 \leq N,K \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Examples Input 7 3 Output 1 Input 100 10 Output 0 Input 1 1 Output 0 Submitted Solution: ``` print("10"[eval(input().replace(" ","%"))==0]) ```
instruction
0
63,827
11
127,654
Yes
output
1
63,827
11
127,655
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Constraints * 1 \leq N,K \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Examples Input 7 3 Output 1 Input 100 10 Output 0 Input 1 1 Output 0 Submitted Solution: ``` print(0 if eval(input().replace(" ","%")) else 1) ```
instruction
0
63,828
11
127,656
No
output
1
63,828
11
127,657
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Constraints * 1 \leq N,K \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Examples Input 7 3 Output 1 Input 100 10 Output 0 Input 1 1 Output 0 Submitted Solution: ``` a, b = (int(i) for i in input().split()) print(int(a % b)) ```
instruction
0
63,829
11
127,658
No
output
1
63,829
11
127,659
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Constraints * 1 \leq N,K \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Examples Input 7 3 Output 1 Input 100 10 Output 0 Input 1 1 Output 0 Submitted Solution: ``` n,k=map(int,input().split()) ans=0 if n%k==0: ans=0 else: ans=n%k print(ans) ```
instruction
0
63,830
11
127,660
No
output
1
63,830
11
127,661
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Constraints * 1 \leq N,K \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: N K Output Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. Examples Input 7 3 Output 1 Input 100 10 Output 0 Input 1 1 Output 0 Submitted Solution: ``` N,K = map(int,input().split()) if N // K == 0: print(0) else: print(1) ```
instruction
0
63,831
11
127,662
No
output
1
63,831
11
127,663