message
stringlengths
2
39.6k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
219
108k
cluster
float64
11
11
__index_level_0__
int64
438
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This problem is interactive. You should guess hidden number x which is between 1 and M = 10004205361450474, inclusive. You could use up to 5 queries. In each query, you can output an increasing sequence of k ≤ x integers, each between 1 and M, inclusive, and you will obtain one of the following as an answer: * either the hidden number belongs to your query sequence, in this case you immediately win; * or you will be given where the hidden number is located with respect to your query sequence, that is, either it is less than all numbers from the sequence, greater than all numbers from the sequence, or you will be given such an i that the hidden number x is between the i-th and the (i+1)-st numbers of your sequence. See the interaction section for clarity. Be aware that the interactor is adaptive, i.e. the hidden number can depend on queries the solution makes. However, it is guaranteed that for any solution the interactor works non-distinguishable from the situation when the hidden number is fixed beforehand. Hacks are allowed only with fixed hidden number. A hack is represented by a single integer between 1 and M. In all pretests the hidden number is fixed as well. Interaction You can make up to 5 queries. To make a query print a number k (1 ≤ k ≤ 10^4) and then an increasing sequence t_0 < t_1 < … < t_{k-1} of k numbers, each between 1 and M, inclusive. If k > x, you lose. You get one integer as a response. * If it is -2, it means you made an invalid query or you lost. Exit immediately after receiving -2 and you will see Wrong answer verdict. Otherwise you can get an arbitrary verdict because your solution will continue to read from a closed stream. * If it is -1, you guessed the number and should terminate too. * Otherwise you get a number i between 0 and k, inclusive, denoting where the hidden number is, with respect to the printed numbers. If i = 0, then x < t_0. If i = k, then t_{k-1} < x. Otherwise t_{i-1} < x < t_i. After printing a query do not forget to output end of line and flush the output. Otherwise you will get Idleness limit exceeded. To do this, use: * fflush(stdout) or cout.flush() in C++; * System.out.flush() in Java; * flush(output) in Pascal; * stdout.flush() in Python; * see documentation for other languages. Example Input   2 0 -1 Output 2 2 3 2 20 30 3 5 7 9 Note In the first example the number 5 is hidden. Submitted Solution: ``` import sys # data = sys.stdin.readlines() start = 1 end = 10004205361450474 print(1, end=' ') print(10000) sys.stdout.flush() t = int(input()) if t < 0: exit(0) elif t == 0: end = 9999 num = 1 print(num, end=' ') print(21) # print(start, end, end - start) # print() sys.stdout.flush() t = int(input()) if t < 0: exit(0) elif t == 0: end = 20 print(1, end = ' ') print(4) sys.stdout.flush() t = int(input()) if t < 0: exit(0) elif t == 0: print(1, end = ' ') print(1) sys.stdout.flush() t = int(input()) if t < 0: exit(0) else: print(2, end = ' ') print(2, 3) sys.stdout.flush() else: start = 5 for i in range(2): num = min(4, end - start + 1) print(num, end=' ') for j in range(num): print(((end - start + 1)//num) * j + start, end=' ') # print(start, end, end - start) print() sys.stdout.flush() t = int(input()) if t < 0: exit(0) elif t == 0: end = (end - start + 1)//num + start elif t == num: start = ((end - start + 1)//num) * num + start else: start, end = ((end - start + 1)//num) * (t-1) + start, ((end - start + 1)//num) * (t) + start else: start = 21 for i in range(3): num = min(20, end - start + 1) print(num, end=' ') for j in range(num): print(((end - start + 1)//num) * j + start, end=' ') # print(start, end, end - start) print() sys.stdout.flush() t = int(input()) if t < 0: exit(0) elif t == 0: end = (end - start + 1)//num + start elif t == num: start = ((end - start + 1)//num) * num + start else: start, end = ((end - start + 1)//num) * (t-1) + start, ((end - start + 1)//num) * (t) + start else: start = 10001 for i in range(4): num = min(10000, end - start + 1) print(num, end=' ') for j in range(num): print(((end - start + 1)//num) * j + start, end=' ') # print(start, end, end - start) print() sys.stdout.flush() t = int(input()) if t < 0: exit(0) elif t == 0: end = (end - start + 1)//num + start elif t == num: start = ((end - start + 1)//num) * num + start else: start, end = ((end - start + 1)//num) * (t-1) + start, ((end - start + 1)//num) * (t) + start ```
instruction
0
78,297
11
156,594
No
output
1
78,297
11
156,595
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call the roundness of the number the number of zeros to which it ends. You have an array of n numbers. You need to choose a subset of exactly k numbers so that the roundness of the product of the selected numbers will be maximum possible. Input The first line contains two integer numbers n and k (1 ≤ n ≤ 200, 1 ≤ k ≤ n). The second line contains n space-separated integer numbers a1, a2, ..., an (1 ≤ ai ≤ 1018). Output Print maximal roundness of product of the chosen subset of length k. Examples Input 3 2 50 4 20 Output 3 Input 5 3 15 16 3 25 9 Output 3 Input 3 3 9 77 13 Output 0 Note In the first example there are 3 subsets of 2 numbers. [50, 4] has product 200 with roundness 2, [4, 20] — product 80, roundness 1, [50, 20] — product 1000, roundness 3. In the second example subset [15, 16, 25] has product 6000, roundness 3. In the third example all subsets has product with roundness 0. Submitted Solution: ``` import itertools def numOfZero(n): res = 0 while n != 0: if n % 10 == 0: res += 1 else: return res n //= 10 n, k = tuple(map(int, input().split())) nums = list(map(int, input().split())) nums = list(filter(lambda x: x % 2 == 0 or x % 10 == 5, nums)) cirle = 0 if len(nums) != 0: combs = itertools.combinations(nums, k) for comb in combs: mult = 1 for i in comb: mult *= i if numOfZero(mult) > cirle: cirle = numOfZero(mult) print(cirle) ```
instruction
0
78,808
11
157,616
No
output
1
78,808
11
157,617
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call the roundness of the number the number of zeros to which it ends. You have an array of n numbers. You need to choose a subset of exactly k numbers so that the roundness of the product of the selected numbers will be maximum possible. Input The first line contains two integer numbers n and k (1 ≤ n ≤ 200, 1 ≤ k ≤ n). The second line contains n space-separated integer numbers a1, a2, ..., an (1 ≤ ai ≤ 1018). Output Print maximal roundness of product of the chosen subset of length k. Examples Input 3 2 50 4 20 Output 3 Input 5 3 15 16 3 25 9 Output 3 Input 3 3 9 77 13 Output 0 Note In the first example there are 3 subsets of 2 numbers. [50, 4] has product 200 with roundness 2, [4, 20] — product 80, roundness 1, [50, 20] — product 1000, roundness 3. In the second example subset [15, 16, 25] has product 6000, roundness 3. In the third example all subsets has product with roundness 0. Submitted Solution: ``` import math def mind(n): d = 0 for i in range(2, math.ceil(n ** 0.5) + 1): if n % i == 0: d = i break if d != 0: return d else: return n def f(l): return min(l.count(2), l.count(5)) n, k = map(int, input().split()) l = [[] for i in range(n)] inp = [int(i) for i in input().split()] for i in range(n): j = inp[i] while j > 1: d = mind(j) j //= d l[i].append(d) l.sort(key = f, reverse = True) out = [] for i in l: out += i print(min(out.count(2), out.count(5))) ```
instruction
0
78,809
11
157,618
No
output
1
78,809
11
157,619
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call the roundness of the number the number of zeros to which it ends. You have an array of n numbers. You need to choose a subset of exactly k numbers so that the roundness of the product of the selected numbers will be maximum possible. Input The first line contains two integer numbers n and k (1 ≤ n ≤ 200, 1 ≤ k ≤ n). The second line contains n space-separated integer numbers a1, a2, ..., an (1 ≤ ai ≤ 1018). Output Print maximal roundness of product of the chosen subset of length k. Examples Input 3 2 50 4 20 Output 3 Input 5 3 15 16 3 25 9 Output 3 Input 3 3 9 77 13 Output 0 Note In the first example there are 3 subsets of 2 numbers. [50, 4] has product 200 with roundness 2, [4, 20] — product 80, roundness 1, [50, 20] — product 1000, roundness 3. In the second example subset [15, 16, 25] has product 6000, roundness 3. In the third example all subsets has product with roundness 0. Submitted Solution: ``` import sys n, k = map(int, input().split()) z = list(map(int, input().split())) gg = [] for i in z: j = i ctr2 = 0 ctr5 = 0 while j % 2 == 0: j //= 2 ctr2 += 1 while j % 5 == 0: j //= 5 ctr5 += 1 gg.append([ctr2, ctr5]) MAXN = 12000 ans = [0] * MAXN for i in range(n): for j in range(MAXN - 1, -1, -1): if (ans[j] != 0 or j == 0): ans[j + gg[i][0]] = max(ans[j + gg[i][0]], ans[j] + gg[i][1]) ret = 0 for i in range(MAXN): ret = max(ret, min(i, ans[i])) print(ret) ```
instruction
0
78,810
11
157,620
No
output
1
78,810
11
157,621
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call the roundness of the number the number of zeros to which it ends. You have an array of n numbers. You need to choose a subset of exactly k numbers so that the roundness of the product of the selected numbers will be maximum possible. Input The first line contains two integer numbers n and k (1 ≤ n ≤ 200, 1 ≤ k ≤ n). The second line contains n space-separated integer numbers a1, a2, ..., an (1 ≤ ai ≤ 1018). Output Print maximal roundness of product of the chosen subset of length k. Examples Input 3 2 50 4 20 Output 3 Input 5 3 15 16 3 25 9 Output 3 Input 3 3 9 77 13 Output 0 Note In the first example there are 3 subsets of 2 numbers. [50, 4] has product 200 with roundness 2, [4, 20] — product 80, roundness 1, [50, 20] — product 1000, roundness 3. In the second example subset [15, 16, 25] has product 6000, roundness 3. In the third example all subsets has product with roundness 0. Submitted Solution: ``` import math from decimal import Decimal import heapq import copy import heapq from collections import deque from collections import defaultdict def na(): n = int(input()) b = [int(x) for x in input().split()] return n,b def nab(): n = int(input()) b = [int(x) for x in input().split()] c = [int(x) for x in input().split()] return n,b,c def dv(): n, m = map(int, input().split()) return n,m def da(): n, m = map(int, input().split()) a = list(map(int, input().split())) return n,m, a def dva(): n, m = map(int, input().split()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] return n,m,b def prost(x): d = math.sqrt(x) d = int(d) + 1 for i in range(2, d): if x % i == 0: return False return True def eratosthenes(n): sieve = list(range(n + 1)) for i in sieve: if i > 1: for j in range(i + i, len(sieve), i): sieve[j] = 0 return sorted(set(sieve)) def lol(lst,k): k=k%len(lst) ret=[0]*len(lst) for i in range(len(lst)): if i+k<len(lst) and i+k>=0: ret[i]=lst[i+k] if i+k>=len(lst): ret[i]=lst[i+k-len(lst)] if i+k<0: ret[i]=lst[i+k+len(lst)] return(ret) def nm(): n = int(input()) b = [int(x) for x in input().split()] m = int(input()) c = [int(x) for x in input().split()] return n,b,m,c def dvs(): n = int(input()) m = int(input()) return n, m n, k = map(int, input().split()) a = list(map(int, input().split())) dp = [] tec = 0 for i in range(n + 1): dp.append([0] * 10001) for i in range(n): k2 = 0 k5 = 0 while a[i] % 5 == 0: k5 += 1 a[i] //= 5 while a[i] % 2 == 0: k2 += 1 a[i] //= 2 tec += k5 for j in range(min(i + 1, k), -1, -1): for kk in range(k5, tec + 1): dp[j][kk] = max(dp[j][kk], dp[j - 1][kk - k5] + k2) ans = 0 for i in range(tec + 1): ans = max(ans, min(i, dp[k][i])) print(ans) ```
instruction
0
78,811
11
157,622
No
output
1
78,811
11
157,623
Provide a correct Python 3 solution for this coding contest problem. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000
instruction
0
78,961
11
157,922
"Correct Solution: ``` n , m = map(int,input().split()) a = m*1900 + (n-m)*100 print(a*2**m) ```
output
1
78,961
11
157,923
Provide a correct Python 3 solution for this coding contest problem. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000
instruction
0
78,962
11
157,924
"Correct Solution: ``` n,m=map(int,input().split()) print((100*n+1800*m)*(2**m)) ```
output
1
78,962
11
157,925
Provide a correct Python 3 solution for this coding contest problem. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000
instruction
0
78,963
11
157,926
"Correct Solution: ``` n,m=[int(i) for i in input().split()] print((m*18+n)*100*2**m) ```
output
1
78,963
11
157,927
Provide a correct Python 3 solution for this coding contest problem. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000
instruction
0
78,964
11
157,928
"Correct Solution: ``` n,m=map(int,input().split()) print(int((100*(n-m)+1900*m)*2**m)) ```
output
1
78,964
11
157,929
Provide a correct Python 3 solution for this coding contest problem. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000
instruction
0
78,965
11
157,930
"Correct Solution: ``` n,m = map(int,input().split()) print(2**m*1900*m + 2**m*100*(n-m)) ```
output
1
78,965
11
157,931
Provide a correct Python 3 solution for this coding contest problem. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000
instruction
0
78,966
11
157,932
"Correct Solution: ``` N,M=map(int,input().split()) ans=pow(2,M)*(1900*M+100*(N-M)) print(ans) ```
output
1
78,966
11
157,933
Provide a correct Python 3 solution for this coding contest problem. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000
instruction
0
78,967
11
157,934
"Correct Solution: ``` N, M = list(map(int, input().split())) print(((N-M)*100+M*1900)*2**M) ```
output
1
78,967
11
157,935
Provide a correct Python 3 solution for this coding contest problem. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000
instruction
0
78,968
11
157,936
"Correct Solution: ``` n,m=map(int, input().split()) x=n-m print(((n-m)*100+1900*m)*2**m) ```
output
1
78,968
11
157,937
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000 Submitted Solution: ``` n,m=map(int,input().split());print(100*(18*m+n)<<m) ```
instruction
0
78,969
11
157,938
Yes
output
1
78,969
11
157,939
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000 Submitted Solution: ``` n,m=map(int,input().split()) print(100*(n+18*m)*(2**m)) ```
instruction
0
78,970
11
157,940
Yes
output
1
78,970
11
157,941
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000 Submitted Solution: ``` n,m=map(int,input().split());print(((n-m)*100+m*1900)*2**m) ```
instruction
0
78,971
11
157,942
Yes
output
1
78,971
11
157,943
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000 Submitted Solution: ``` N,M=map(int,input().split()) print((100*(N-M)+1900*M)*2**M) ```
instruction
0
78,972
11
157,944
Yes
output
1
78,972
11
157,945
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000 Submitted Solution: ``` N,M=map(int,input().split()) p=(1/2)**M listP=[p] listP+=[0]*(10**6) sumP=[0]*(10**6) sumP[0]=p ans=0 time=1900*M+100*(N-M) for i in range(10**5): ans+=time*listP[i]*(i+1) sumP[i+1]=sumP[i]+p*(1-sumP[i]) listP[i+1]=p*(1-sumP[i]) print(int(ans)) ```
instruction
0
78,973
11
157,946
No
output
1
78,973
11
157,947
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000 Submitted Solution: ``` import sys input = sys.stdin.readline n,m = map(int, input().split()) print((1900*m + 100(N − M))*2**m) ```
instruction
0
78,974
11
157,948
No
output
1
78,974
11
157,949
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000 Submitted Solution: ``` n, m = map(int, input().split()) if n==m: print(3800) else: s = (1900*m + (n-m)*100)*n*2**m x = 10**(len(str(n))-1) print(s//x) ```
instruction
0
78,975
11
157,950
No
output
1
78,975
11
157,951
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). Constraints * All input values are integers. * 1 \leq N \leq 100 * 1 \leq M \leq {\rm min}(N, 5) Input Input is given from Standard Input in the following format: N M Output Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. Examples Input 1 1 Output 3800 Input 10 2 Output 18400 Input 100 5 Output 608000 Submitted Solution: ``` n, m = map(int,input().split()) ans = 0 count = 0 import math not_c = 1-(1/2)**m c = (1/ 2) ** m s = 1900 #k-1 回目まで不正解かつ k回目で終わる確率は # (not_c ** (k-1)) * c 199 # k回目までに(s * k)が重み付け ans = s * c /((1-not_c) ** 2) print(int(ans)) ```
instruction
0
78,976
11
157,952
No
output
1
78,976
11
157,953
Provide tags and a correct Python 3 solution for this coding contest problem. The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds. The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination. As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at least n·m people go to the finals, and the total amount of used problems in all rounds is as small as possible. Input The first line contains two integers c and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k (1 ≤ k ≤ 100) — the number of the pre-chosen winners. Output In the first line, print a single integer — the minimum number of problems the jury needs to prepare. Examples Input 1 10 7 2 1 Output 2 Input 2 2 2 1 2 Output 0
instruction
0
79,480
11
158,960
Tags: dp, implementation, math Correct Solution: ``` # Made By Mostafa_Khaled bot = True c, d = list(map(int, input().split())) n, m = list(map(int, input().split())) k = int(input()) kolvo = m * n - k if kolvo < 0: print(0) exit() print(min(c * (kolvo // n), d * n * (kolvo // n)) + min(c, d * (kolvo % n))) # Made By Mostafa_Khaled ```
output
1
79,480
11
158,961
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds. The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination. As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at least n·m people go to the finals, and the total amount of used problems in all rounds is as small as possible. Input The first line contains two integers c and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k (1 ≤ k ≤ 100) — the number of the pre-chosen winners. Output In the first line, print a single integer — the minimum number of problems the jury needs to prepare. Examples Input 1 10 7 2 1 Output 2 Input 2 2 2 1 2 Output 0 Submitted Solution: ``` c,d = list(map(int,input().split())) n,m = list(map(int,input().split())) k = int(input()) t = max((m*n)-k,0) p = min(c,n*d) ans = p*(t//n) rem = t%n ans = ans+min(c,rem*d) print(ans) ```
instruction
0
79,481
11
158,962
Yes
output
1
79,481
11
158,963
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds. The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination. As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at least n·m people go to the finals, and the total amount of used problems in all rounds is as small as possible. Input The first line contains two integers c and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k (1 ≤ k ≤ 100) — the number of the pre-chosen winners. Output In the first line, print a single integer — the minimum number of problems the jury needs to prepare. Examples Input 1 10 7 2 1 Output 2 Input 2 2 2 1 2 Output 0 Submitted Solution: ``` import math c,d = map(int,input().split()) n,m = map(int,input().split()) k = int(input()) if k>=n*m: print (0) exit() left = n*m-k print (min(math.ceil(left/n)*c,(left//n)*c + (left%n)*d,left*d)) ```
instruction
0
79,482
11
158,964
Yes
output
1
79,482
11
158,965
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds. The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination. As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at least n·m people go to the finals, and the total amount of used problems in all rounds is as small as possible. Input The first line contains two integers c and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k (1 ≤ k ≤ 100) — the number of the pre-chosen winners. Output In the first line, print a single integer — the minimum number of problems the jury needs to prepare. Examples Input 1 10 7 2 1 Output 2 Input 2 2 2 1 2 Output 0 Submitted Solution: ``` #import sys #sys.stdin = open('input.txt','r') c, d = map(int, input().split()) n, m = map(int, input().split()) k = int(input()) L = 10001 for f in range(m + 1): for g in range(n * m + 1): if f * n + g + k >= n * m: L = min(L, f * c + g * d) print(L) ```
instruction
0
79,483
11
158,966
Yes
output
1
79,483
11
158,967
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds. The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination. As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at least n·m people go to the finals, and the total amount of used problems in all rounds is as small as possible. Input The first line contains two integers c and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k (1 ≤ k ≤ 100) — the number of the pre-chosen winners. Output In the first line, print a single integer — the minimum number of problems the jury needs to prepare. Examples Input 1 10 7 2 1 Output 2 Input 2 2 2 1 2 Output 0 Submitted Solution: ``` c,d=map(int,input().split()) n,m=map(int,input().split()) k=int(input()) tot=n*m if(k>=tot): print("0") else: rem=tot-k x=n/c y=1/d ans=0 if(x>=y): temp=rem//n bacha=rem%n if(bacha*d<=c): ans=temp*c+bacha*d else: ans=(temp+1)*c else: ans=rem*d print(ans) ```
instruction
0
79,484
11
158,968
Yes
output
1
79,484
11
158,969
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds. The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination. As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at least n·m people go to the finals, and the total amount of used problems in all rounds is as small as possible. Input The first line contains two integers c and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k (1 ≤ k ≤ 100) — the number of the pre-chosen winners. Output In the first line, print a single integer — the minimum number of problems the jury needs to prepare. Examples Input 1 10 7 2 1 Output 2 Input 2 2 2 1 2 Output 0 Submitted Solution: ``` import math c,d=map(int,input('').split()) n,m=map(int,input('').split()) k=int(input('')) if k<0: print('0') exit() if 1/d>n/c: print((n*m-k)*d) else: if (math.ceil((n*m-k)/n)*c)<((n*m-k)//n)*c+((n*m-k)%n)*d: print (math.ceil((n*m-k)/n)*c) else: print(((n*m-k)//n)*c+((n*m-k)%n)*d) ```
instruction
0
79,485
11
158,970
No
output
1
79,485
11
158,971
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds. The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination. As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at least n·m people go to the finals, and the total amount of used problems in all rounds is as small as possible. Input The first line contains two integers c and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k (1 ≤ k ≤ 100) — the number of the pre-chosen winners. Output In the first line, print a single integer — the minimum number of problems the jury needs to prepare. Examples Input 1 10 7 2 1 Output 2 Input 2 2 2 1 2 Output 0 Submitted Solution: ``` c,d = [int(x) for x in input().strip().split()] n,m = [int(x) for x in input().strip().split()] k = int(input().strip()) t = n*m-k if t<=0: print(0) else: dp = [0]*(t+1) for i in range(1,t+1): if i<n: dp[i]=min(dp[i-1]+d, n) else: dp[i]=min((c+dp[i-n]), (d+dp[i-1])) print(dp[t]) ```
instruction
0
79,486
11
158,972
No
output
1
79,486
11
158,973
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds. The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination. As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at least n·m people go to the finals, and the total amount of used problems in all rounds is as small as possible. Input The first line contains two integers c and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k (1 ≤ k ≤ 100) — the number of the pre-chosen winners. Output In the first line, print a single integer — the minimum number of problems the jury needs to prepare. Examples Input 1 10 7 2 1 Output 2 Input 2 2 2 1 2 Output 0 Submitted Solution: ``` #import sys #sys.stdin = open('input.txt','r') c, d = map(int, input().split()) n, m = map(int, input().split()) k = int(input()) L = 10001 for f in range(m + 1): for g in range(n * m + 1): if f * n * c + g * d + k >= n * m: L = min(L, f * c + g * d) print(L) ```
instruction
0
79,487
11
158,974
No
output
1
79,487
11
158,975
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds. The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination. As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at least n·m people go to the finals, and the total amount of used problems in all rounds is as small as possible. Input The first line contains two integers c and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k (1 ≤ k ≤ 100) — the number of the pre-chosen winners. Output In the first line, print a single integer — the minimum number of problems the jury needs to prepare. Examples Input 1 10 7 2 1 Output 2 Input 2 2 2 1 2 Output 0 Submitted Solution: ``` def f(x, y): return x * c + y * d c, d = map(int, input().split()) n, m = map(int, input().split()) k = s = n * m - int(input()) x = 0 while k > x * n: t = f(x, k - x * n) if t < s: s = t x += 1 print(min(s, f(x, 0))) ```
instruction
0
79,488
11
158,976
No
output
1
79,488
11
158,977
Provide tags and a correct Python 3 solution for this coding contest problem. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26.
instruction
0
79,489
11
158,978
Tags: greedy, math, probabilities Correct Solution: ``` from functools import reduce L0 = [] def getP(): return sum([reduce(lambda y, x: y*x, [(L0[j] if j == i else (1 - L0[j])) for j in range(len(L0))], 1) for i in range(len(L0))]) input() L = [float(x) for x in input().split()] #inp = open('input.txt') #inp.readline() #L = [float(x) for x in inp.readline().split()] #inp.close() L.sort(reverse=True) if len(L) > 0 and L[0] == 1: print(1) else: S = 0 for p in L: if S < 1: S += p/(1 - p) L0.append(p) else: break print(getP()) ```
output
1
79,489
11
158,979
Provide tags and a correct Python 3 solution for this coding contest problem. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26.
instruction
0
79,490
11
158,980
Tags: greedy, math, probabilities Correct Solution: ``` n = int(input()) p = sorted(map(float, input().split()), reverse=True) np = 1.0 - p[0] pp = p[0] ans = pp for i in range(1, len(p)): pp *= 1.0 - p[i] pp += p[i] * np np *= 1.0 - p[i] if ans < pp: ans = pp else: break print(ans) ```
output
1
79,490
11
158,981
Provide tags and a correct Python 3 solution for this coding contest problem. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26.
instruction
0
79,491
11
158,982
Tags: greedy, math, probabilities Correct Solution: ``` n = int(input()) pr = list(map(float, input().split())) pr.sort(reverse = True) p = (1 - pr[0]) if (p == 0): print(1) else: s = pr[0] / (1 - pr[0]) pps = p * s for i in range(1, len(pr)): p *= 1 - pr[i] s += pr[i] / (1 - pr[i]) ps = p * s if pps > ps: break pps = ps print(pps) ```
output
1
79,491
11
158,983
Provide tags and a correct Python 3 solution for this coding contest problem. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26.
instruction
0
79,492
11
158,984
Tags: greedy, math, probabilities Correct Solution: ``` input() p = sorted(map(float, input().split(' '))) m = max(p) p = [(1 - i, i) for i in p] def konv(a, b): return a[0] * b[0], a[0] * b[1] + a[1] * b[0] while len(p) > 1: p.append(konv(p.pop(), p.pop())) m = max(m, p[-1][1]) print(m) ```
output
1
79,492
11
158,985
Provide tags and a correct Python 3 solution for this coding contest problem. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26.
instruction
0
79,493
11
158,986
Tags: greedy, math, probabilities Correct Solution: ``` def readln(): return tuple(map(int, input().split())) n, = readln() ans = tmp = 0.0 prod = 1.0 for p in reversed(sorted(map(float, input().split()))): tmp = tmp * (1.0 - p) + prod * p prod *= 1.0 - p #print(ans, tmp, prod, p) ans = max(ans, tmp) print('%0.9f' % ans) ```
output
1
79,493
11
158,987
Provide tags and a correct Python 3 solution for this coding contest problem. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26.
instruction
0
79,494
11
158,988
Tags: greedy, math, probabilities Correct Solution: ``` n = input() ans = tmp = 0.0 prod = 1.0 for p in reversed(sorted(map(float, input().split()))): tmp = tmp * (1.0 - p) + prod * p prod *= 1.0 - p ans = max(ans, tmp) print('%0.9f' % ans) ```
output
1
79,494
11
158,989
Provide tags and a correct Python 3 solution for this coding contest problem. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26.
instruction
0
79,495
11
158,990
Tags: greedy, math, probabilities Correct Solution: ``` #!/usr/bin/python3 import sys n = int(sys.stdin.readline()) p = [float(x) for x in sys.stdin.readline().split()] p.sort() d = [(1-x, x, 0) for x in p] m = max(p) def konv(a, b): return (a[0]*b[0], a[0]*b[1] + a[1]*b[0], 0) while len(d) > 1: a = d.pop() b = d.pop() c = konv(a, b) m = max(m, c[1]) d.append(c) print(m) ```
output
1
79,495
11
158,991
Provide tags and a correct Python 3 solution for this coding contest problem. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26.
instruction
0
79,496
11
158,992
Tags: greedy, math, probabilities Correct Solution: ``` n = input() ans = tmp = 0.0 pd = 1.0 for i in reversed(sorted(map(float, input().split()))): tmp = tmp * (1.0 - i) + pd * i pd *= 1.0 - i ans = max(ans, tmp) print('%0.12f' % ans) ```
output
1
79,496
11
158,993
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26. Submitted Solution: ``` n = int(input()) a = list(reversed(sorted(list(map(float, input().split()))))) A = a[0] B = 1 - a[0] for i in range(1, n): if (1 - a[i]) * A + a[i] * B > A: A = (1 - a[i]) * A + a[i] * B B *= (1 - a[i]) print(A) ```
instruction
0
79,497
11
158,994
Yes
output
1
79,497
11
158,995
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26. Submitted Solution: ``` # -*- coding: utf-8 -*- import sys f = sys.stdin n = int(f.readline().strip()) p = [float(u) for u in f.readline().strip().split()] p.sort(reverse=True) #p.sort() p0 = 1 p1 = 0 p2 = 0 for pi in p: p0t, p1t = p0*(1-pi), p0*pi+p1*(1-pi) #print(p1t) if p1t > p1 : p0, p1 = p0t, p1t else: break #print(p, p0, p1, p1t) print(p1) ```
instruction
0
79,498
11
158,996
Yes
output
1
79,498
11
158,997
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26. Submitted Solution: ``` n=input() p=[float(x) for x in input().split()] p.sort(reverse=True) maxans=0 for i in range(len(p)): ans=0 for j in range(i+1): temp=p[j] for k in range(i+1): if k!=j:temp*=(1-p[k]) ans+=temp if ans>maxans : maxans=ans print(maxans) ```
instruction
0
79,499
11
158,998
Yes
output
1
79,499
11
158,999
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26. Submitted Solution: ``` from functools import reduce L0 = [] pMax = 0 def getP(): return sum([reduce(lambda y, x: y*x, [(L0[j] if j == i else (1 - L0[j])) for j in range(len(L0))], 1) for i in range(len(L0))]) input() L = [float(x) for x in input().split()] #inp = open('input.txt') #inp.readline() #L = [float(x) for x in inp.readline().split()] #inp.close() L.reverse() def go(stInd): global pMax for i in range(stInd, len(L)): L0.append(L[i]) print(L0) p = getP() if p > pMax: pMax = p go(stInd + 1) L0.pop(-1) go(0) print(pMax) ```
instruction
0
79,500
11
159,000
No
output
1
79,500
11
159,001
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26. Submitted Solution: ``` n=input() p=[float(x) for x in input().split()] p.sort(reverse=True) now=0 for x in p: if now<now+x-2*now*x: now=now+x-2*now*x print(now) ```
instruction
0
79,501
11
159,002
No
output
1
79,501
11
159,003
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26. Submitted Solution: ``` from functools import reduce L0 = [] pMax = 0 def getP(): return sum([reduce(lambda y, x: y*x, [(L0[j] if j == i else (1 - L0[j])) for j in range(len(L0))], 1) for i in range(len(L0))]) input() L = [float(x) for x in input().split()] def go(stInd): global pMax for i in range(stInd, len(L)): L0.append(L[i]) p = getP() if p > pMax: pMax = p go(stInd + 1) L0.pop(0) go(0) print(pMax) ```
instruction
0
79,502
11
159,004
No
output
1
79,502
11
159,005
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset. Input The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point. Output Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9. Examples Input 4 0.1 0.2 0.3 0.8 Output 0.800000000000 Input 2 0.1 0.2 Output 0.260000000000 Note In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one. In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26. Submitted Solution: ``` from functools import reduce def getP(L, ind): return sum([reduce(lambda y, x: y*x, [(L[j] if j == i else (1 - L[j])) for j in range(len(L)) if j != ind], 1) for i in range(len(L)) if i != ind]) input() L = [float(x) for x in input().split()] p0 = getP(L, -1) stp = False while not stp: for ind in range(len(L)): p1 = getP(L, ind) if p0 < p1: L.pop(ind) p0 = p1 break else: print(p0) stp = True ```
instruction
0
79,503
11
159,006
No
output
1
79,503
11
159,007
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Because of budget cuts one IT company established new non-financial reward system instead of bonuses. Two kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed a critical bug gets "I fixed a critical bug" pennant on his table. A man who suggested a new interesting feature gets "I suggested a new feature" pennant on his table. Because of the limited budget of the new reward system only 5 "I fixed a critical bug" pennants and 3 "I suggested a new feature" pennants were bought. In order to use these pennants for a long time they were made challenge ones. When a man fixes a new critical bug one of the earlier awarded "I fixed a critical bug" pennants is passed on to his table. When a man suggests a new interesting feature one of the earlier awarded "I suggested a new feature" pennants is passed on to his table. One man can have several pennants of one type and of course he can have pennants of both types on his table. There are n tables in the IT company. Find the number of ways to place the pennants on these tables given that each pennant is situated on one of the tables and each table is big enough to contain any number of pennants. Input The only line of the input contains one integer n (1 ≤ n ≤ 500) — the number of tables in the IT company. Output Output one integer — the amount of ways to place the pennants on n tables. Examples Input 2 Output 24 Submitted Solution: ``` from math import factorial as f n = int(input()) def b(n, k): return f(n)//f(k)//f(n-k) s5 = n if (n > 1): s5 += n*(n-1)*2 if (n > 2): s5 += n*(n-1)*(n-2)//2*2 if (n > 3): s5 += n*(n-1)*(n-2)*(n-3)//f(3) if (n > 4): s5 += n*(n-1)*(n-2)*(n-3)*(n-4)//f(5) s3 = n if (n > 1): s3 += n*(n-1) if (n > 2): s3 += n*(n-1)*(n-2)//6 #print(s5, s3) print(s5*s3) ```
instruction
0
79,571
11
159,142
Yes
output
1
79,571
11
159,143
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Because of budget cuts one IT company established new non-financial reward system instead of bonuses. Two kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed a critical bug gets "I fixed a critical bug" pennant on his table. A man who suggested a new interesting feature gets "I suggested a new feature" pennant on his table. Because of the limited budget of the new reward system only 5 "I fixed a critical bug" pennants and 3 "I suggested a new feature" pennants were bought. In order to use these pennants for a long time they were made challenge ones. When a man fixes a new critical bug one of the earlier awarded "I fixed a critical bug" pennants is passed on to his table. When a man suggests a new interesting feature one of the earlier awarded "I suggested a new feature" pennants is passed on to his table. One man can have several pennants of one type and of course he can have pennants of both types on his table. There are n tables in the IT company. Find the number of ways to place the pennants on these tables given that each pennant is situated on one of the tables and each table is big enough to contain any number of pennants. Input The only line of the input contains one integer n (1 ≤ n ≤ 500) — the number of tables in the IT company. Output Output one integer — the amount of ways to place the pennants on n tables. Examples Input 2 Output 24 Submitted Solution: ``` n=int(input()) print((n*(n+1)*(n+2)*(n+3)*(n+4)*n*(n+1)*(n+2))//720) ```
instruction
0
79,572
11
159,144
Yes
output
1
79,572
11
159,145
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Because of budget cuts one IT company established new non-financial reward system instead of bonuses. Two kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed a critical bug gets "I fixed a critical bug" pennant on his table. A man who suggested a new interesting feature gets "I suggested a new feature" pennant on his table. Because of the limited budget of the new reward system only 5 "I fixed a critical bug" pennants and 3 "I suggested a new feature" pennants were bought. In order to use these pennants for a long time they were made challenge ones. When a man fixes a new critical bug one of the earlier awarded "I fixed a critical bug" pennants is passed on to his table. When a man suggests a new interesting feature one of the earlier awarded "I suggested a new feature" pennants is passed on to his table. One man can have several pennants of one type and of course he can have pennants of both types on his table. There are n tables in the IT company. Find the number of ways to place the pennants on these tables given that each pennant is situated on one of the tables and each table is big enough to contain any number of pennants. Input The only line of the input contains one integer n (1 ≤ n ≤ 500) — the number of tables in the IT company. Output Output one integer — the amount of ways to place the pennants on n tables. Examples Input 2 Output 24 Submitted Solution: ``` import math as ma def fu(n,r): return (ma.factorial(n)//(ma.factorial(n-r)*ma.factorial(r))) n=int(input()) s=0 t=0 for i in range(4,5): s+=fu(n+i,i+1) for i in range(2,3): t+=fu(n+i,i+1) print(s*t) ```
instruction
0
79,573
11
159,146
Yes
output
1
79,573
11
159,147
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Because of budget cuts one IT company established new non-financial reward system instead of bonuses. Two kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed a critical bug gets "I fixed a critical bug" pennant on his table. A man who suggested a new interesting feature gets "I suggested a new feature" pennant on his table. Because of the limited budget of the new reward system only 5 "I fixed a critical bug" pennants and 3 "I suggested a new feature" pennants were bought. In order to use these pennants for a long time they were made challenge ones. When a man fixes a new critical bug one of the earlier awarded "I fixed a critical bug" pennants is passed on to his table. When a man suggests a new interesting feature one of the earlier awarded "I suggested a new feature" pennants is passed on to his table. One man can have several pennants of one type and of course he can have pennants of both types on his table. There are n tables in the IT company. Find the number of ways to place the pennants on these tables given that each pennant is situated on one of the tables and each table is big enough to contain any number of pennants. Input The only line of the input contains one integer n (1 ≤ n ≤ 500) — the number of tables in the IT company. Output Output one integer — the amount of ways to place the pennants on n tables. Examples Input 2 Output 24 Submitted Solution: ``` import operator as op from functools import reduce def ncr(n, r): r = min(r, n-r) numer = reduce(op.mul, range(n, n-r, -1), 1) denom = reduce(op.mul, range(1, r+1), 1) return numer // denom n = int(input()) print(ncr(3+n-1,n-1)*ncr(5+n-1,n-1)) ```
instruction
0
79,574
11
159,148
Yes
output
1
79,574
11
159,149
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Because of budget cuts one IT company established new non-financial reward system instead of bonuses. Two kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed a critical bug gets "I fixed a critical bug" pennant on his table. A man who suggested a new interesting feature gets "I suggested a new feature" pennant on his table. Because of the limited budget of the new reward system only 5 "I fixed a critical bug" pennants and 3 "I suggested a new feature" pennants were bought. In order to use these pennants for a long time they were made challenge ones. When a man fixes a new critical bug one of the earlier awarded "I fixed a critical bug" pennants is passed on to his table. When a man suggests a new interesting feature one of the earlier awarded "I suggested a new feature" pennants is passed on to his table. One man can have several pennants of one type and of course he can have pennants of both types on his table. There are n tables in the IT company. Find the number of ways to place the pennants on these tables given that each pennant is situated on one of the tables and each table is big enough to contain any number of pennants. Input The only line of the input contains one integer n (1 ≤ n ≤ 500) — the number of tables in the IT company. Output Output one integer — the amount of ways to place the pennants on n tables. Examples Input 2 Output 24 Submitted Solution: ``` from math import factorial f = factorial k = int(input()) n1 = 5 n2 = 3 ans1 = f(k + n1 - 1) / f(k - 1) / f(n1) ans2 = f(k + n2 - 1) / f(k - 1) / f(n2) print(int(ans1 * ans2)) # n!/(n − m)!/m! ```
instruction
0
79,575
11
159,150
No
output
1
79,575
11
159,151