message
stringlengths
2
22.7k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
145
109k
cluster
float64
9
9
__index_level_0__
int64
290
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have n gifts and you want to give all of them to children. Of course, you don't want to offend anyone, so all gifts should be equal between each other. The i-th gift consists of a_i candies and b_i oranges. During one move, you can choose some gift 1 ≤ i ≤ n and do one of the following operations: * eat exactly one candy from this gift (decrease a_i by one); * eat exactly one orange from this gift (decrease b_i by one); * eat exactly one candy and exactly one orange from this gift (decrease both a_i and b_i by one). Of course, you can not eat a candy or orange if it's not present in the gift (so neither a_i nor b_i can become less than zero). As said above, all gifts should be equal. This means that after some sequence of moves the following two conditions should be satisfied: a_1 = a_2 = ... = a_n and b_1 = b_2 = ... = b_n (and a_i equals b_i is not necessary). Your task is to find the minimum number of moves required to equalize all the given gifts. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow. The first line of the test case contains one integer n (1 ≤ n ≤ 50) — the number of gifts. The second line of the test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9), where a_i is the number of candies in the i-th gift. The third line of the test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9), where b_i is the number of oranges in the i-th gift. Output For each test case, print one integer: the minimum number of moves required to equalize all the given gifts. Example Input 5 3 3 5 6 3 2 3 5 1 2 3 4 5 5 4 3 2 1 3 1 1 1 2 2 2 6 1 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1 1 1 1 3 10 12 8 7 5 4 Output 6 16 0 4999999995 7 Note In the first test case of the example, we can perform the following sequence of moves: * choose the first gift and eat one orange from it, so a = [3, 5, 6] and b = [2, 2, 3]; * choose the second gift and eat one candy from it, so a = [3, 4, 6] and b = [2, 2, 3]; * choose the second gift and eat one candy from it, so a = [3, 3, 6] and b = [2, 2, 3]; * choose the third gift and eat one candy and one orange from it, so a = [3, 3, 5] and b = [2, 2, 2]; * choose the third gift and eat one candy from it, so a = [3, 3, 4] and b = [2, 2, 2]; * choose the third gift and eat one candy from it, so a = [3, 3, 3] and b = [2, 2, 2]. Submitted Solution: ``` for _ in range(int(input())): n = int(input()) arr = list(map(int,input().split())) arrb = list(map(int,input().split())) c = 0 if(len(set(arr)) == len(set(arrb))==1): print(0) else: a = min(arr) b = min(arrb) for i in range(n): if(arr[i]>a and arrb[i]>b): c+=max(arr[i]-a,arrb[i]-b) else: c+=max(arr[i]-a,arrb[i]-b) print(c) ```
instruction
0
41,442
9
82,884
Yes
output
1
41,442
9
82,885
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have n gifts and you want to give all of them to children. Of course, you don't want to offend anyone, so all gifts should be equal between each other. The i-th gift consists of a_i candies and b_i oranges. During one move, you can choose some gift 1 ≤ i ≤ n and do one of the following operations: * eat exactly one candy from this gift (decrease a_i by one); * eat exactly one orange from this gift (decrease b_i by one); * eat exactly one candy and exactly one orange from this gift (decrease both a_i and b_i by one). Of course, you can not eat a candy or orange if it's not present in the gift (so neither a_i nor b_i can become less than zero). As said above, all gifts should be equal. This means that after some sequence of moves the following two conditions should be satisfied: a_1 = a_2 = ... = a_n and b_1 = b_2 = ... = b_n (and a_i equals b_i is not necessary). Your task is to find the minimum number of moves required to equalize all the given gifts. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow. The first line of the test case contains one integer n (1 ≤ n ≤ 50) — the number of gifts. The second line of the test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9), where a_i is the number of candies in the i-th gift. The third line of the test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9), where b_i is the number of oranges in the i-th gift. Output For each test case, print one integer: the minimum number of moves required to equalize all the given gifts. Example Input 5 3 3 5 6 3 2 3 5 1 2 3 4 5 5 4 3 2 1 3 1 1 1 2 2 2 6 1 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1 1 1 1 3 10 12 8 7 5 4 Output 6 16 0 4999999995 7 Note In the first test case of the example, we can perform the following sequence of moves: * choose the first gift and eat one orange from it, so a = [3, 5, 6] and b = [2, 2, 3]; * choose the second gift and eat one candy from it, so a = [3, 4, 6] and b = [2, 2, 3]; * choose the second gift and eat one candy from it, so a = [3, 3, 6] and b = [2, 2, 3]; * choose the third gift and eat one candy and one orange from it, so a = [3, 3, 5] and b = [2, 2, 2]; * choose the third gift and eat one candy from it, so a = [3, 3, 4] and b = [2, 2, 2]; * choose the third gift and eat one candy from it, so a = [3, 3, 3] and b = [2, 2, 2]. Submitted Solution: ``` t, an = int(input()), [] for i in range(t): n, a, b = int(input()), [int(j) for j in input().split()], [int(h) for h in input().split()] am = min(a) bm = min(b) an.append(0) for e in range(n): an[i] += max((a[e] - am), (b[e] - bm)) print('\n'.join([str(i) for i in an])) ```
instruction
0
41,443
9
82,886
Yes
output
1
41,443
9
82,887
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have n gifts and you want to give all of them to children. Of course, you don't want to offend anyone, so all gifts should be equal between each other. The i-th gift consists of a_i candies and b_i oranges. During one move, you can choose some gift 1 ≤ i ≤ n and do one of the following operations: * eat exactly one candy from this gift (decrease a_i by one); * eat exactly one orange from this gift (decrease b_i by one); * eat exactly one candy and exactly one orange from this gift (decrease both a_i and b_i by one). Of course, you can not eat a candy or orange if it's not present in the gift (so neither a_i nor b_i can become less than zero). As said above, all gifts should be equal. This means that after some sequence of moves the following two conditions should be satisfied: a_1 = a_2 = ... = a_n and b_1 = b_2 = ... = b_n (and a_i equals b_i is not necessary). Your task is to find the minimum number of moves required to equalize all the given gifts. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow. The first line of the test case contains one integer n (1 ≤ n ≤ 50) — the number of gifts. The second line of the test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9), where a_i is the number of candies in the i-th gift. The third line of the test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9), where b_i is the number of oranges in the i-th gift. Output For each test case, print one integer: the minimum number of moves required to equalize all the given gifts. Example Input 5 3 3 5 6 3 2 3 5 1 2 3 4 5 5 4 3 2 1 3 1 1 1 2 2 2 6 1 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1 1 1 1 3 10 12 8 7 5 4 Output 6 16 0 4999999995 7 Note In the first test case of the example, we can perform the following sequence of moves: * choose the first gift and eat one orange from it, so a = [3, 5, 6] and b = [2, 2, 3]; * choose the second gift and eat one candy from it, so a = [3, 4, 6] and b = [2, 2, 3]; * choose the second gift and eat one candy from it, so a = [3, 3, 6] and b = [2, 2, 3]; * choose the third gift and eat one candy and one orange from it, so a = [3, 3, 5] and b = [2, 2, 2]; * choose the third gift and eat one candy from it, so a = [3, 3, 4] and b = [2, 2, 2]; * choose the third gift and eat one candy from it, so a = [3, 3, 3] and b = [2, 2, 2]. Submitted Solution: ``` for _ in range(int(input())): n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) ma=min(a) mb=min(b) c=0 for i in range(n): c=c+max(a[i]-ma,b[i]-mb) print(c) ```
instruction
0
41,444
9
82,888
Yes
output
1
41,444
9
82,889
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have n gifts and you want to give all of them to children. Of course, you don't want to offend anyone, so all gifts should be equal between each other. The i-th gift consists of a_i candies and b_i oranges. During one move, you can choose some gift 1 ≤ i ≤ n and do one of the following operations: * eat exactly one candy from this gift (decrease a_i by one); * eat exactly one orange from this gift (decrease b_i by one); * eat exactly one candy and exactly one orange from this gift (decrease both a_i and b_i by one). Of course, you can not eat a candy or orange if it's not present in the gift (so neither a_i nor b_i can become less than zero). As said above, all gifts should be equal. This means that after some sequence of moves the following two conditions should be satisfied: a_1 = a_2 = ... = a_n and b_1 = b_2 = ... = b_n (and a_i equals b_i is not necessary). Your task is to find the minimum number of moves required to equalize all the given gifts. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow. The first line of the test case contains one integer n (1 ≤ n ≤ 50) — the number of gifts. The second line of the test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9), where a_i is the number of candies in the i-th gift. The third line of the test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9), where b_i is the number of oranges in the i-th gift. Output For each test case, print one integer: the minimum number of moves required to equalize all the given gifts. Example Input 5 3 3 5 6 3 2 3 5 1 2 3 4 5 5 4 3 2 1 3 1 1 1 2 2 2 6 1 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1 1 1 1 3 10 12 8 7 5 4 Output 6 16 0 4999999995 7 Note In the first test case of the example, we can perform the following sequence of moves: * choose the first gift and eat one orange from it, so a = [3, 5, 6] and b = [2, 2, 3]; * choose the second gift and eat one candy from it, so a = [3, 4, 6] and b = [2, 2, 3]; * choose the second gift and eat one candy from it, so a = [3, 3, 6] and b = [2, 2, 3]; * choose the third gift and eat one candy and one orange from it, so a = [3, 3, 5] and b = [2, 2, 2]; * choose the third gift and eat one candy from it, so a = [3, 3, 4] and b = [2, 2, 2]; * choose the third gift and eat one candy from it, so a = [3, 3, 3] and b = [2, 2, 2]. Submitted Solution: ``` def find_min(lis1,lis2): min_candies = lis1[0] min_oranges = lis2[0] for ind, i in enumerate(lis1): if i < min_candies: min_candies = i if lis2[ind] < min_oranges: min_oranges = lis2[ind] return [min_candies, min_oranges] print(find_min([1, 2, 3, 4, 5],[5, 4, 3, 2, 1])) def compare(a, b): if a <= b: return a return b def gift1(candies, oranges, min_candies_oranges): # first two are numbers and the last is list with size 2 min_candies, min_oranges = min_candies_oranges dif_candies = candies - min_candies dif_oranges = oranges - min_oranges to_eat_together = compare(dif_candies, dif_oranges) to_eat_orange = dif_oranges - to_eat_together to_eat_candies = dif_candies - to_eat_together return (to_eat_together + to_eat_candies + to_eat_orange) #print(gift1(6, 6, [1, 1])) def man(): list_1 = [] list_2 = [] list_3 = [] k = [] a = input() for i in range(3 * int(a)): a = input() if len(a) == 1: continue else: a = [int(i) for i in a.split()] k.append(a) if (i + 1) % 3 == 0: if k: list_1.append(k) k = [] for i in list_1: min_candies_oranges = find_min(i[0], i[1]) sum = 0 for loc, j in enumerate(i[0]): sum += gift1(j, i[1][loc], min_candies_oranges) list_2.append(str(sum)) return "\n".join(list_2) ```
instruction
0
41,445
9
82,890
No
output
1
41,445
9
82,891
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have n gifts and you want to give all of them to children. Of course, you don't want to offend anyone, so all gifts should be equal between each other. The i-th gift consists of a_i candies and b_i oranges. During one move, you can choose some gift 1 ≤ i ≤ n and do one of the following operations: * eat exactly one candy from this gift (decrease a_i by one); * eat exactly one orange from this gift (decrease b_i by one); * eat exactly one candy and exactly one orange from this gift (decrease both a_i and b_i by one). Of course, you can not eat a candy or orange if it's not present in the gift (so neither a_i nor b_i can become less than zero). As said above, all gifts should be equal. This means that after some sequence of moves the following two conditions should be satisfied: a_1 = a_2 = ... = a_n and b_1 = b_2 = ... = b_n (and a_i equals b_i is not necessary). Your task is to find the minimum number of moves required to equalize all the given gifts. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow. The first line of the test case contains one integer n (1 ≤ n ≤ 50) — the number of gifts. The second line of the test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9), where a_i is the number of candies in the i-th gift. The third line of the test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9), where b_i is the number of oranges in the i-th gift. Output For each test case, print one integer: the minimum number of moves required to equalize all the given gifts. Example Input 5 3 3 5 6 3 2 3 5 1 2 3 4 5 5 4 3 2 1 3 1 1 1 2 2 2 6 1 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1 1 1 1 3 10 12 8 7 5 4 Output 6 16 0 4999999995 7 Note In the first test case of the example, we can perform the following sequence of moves: * choose the first gift and eat one orange from it, so a = [3, 5, 6] and b = [2, 2, 3]; * choose the second gift and eat one candy from it, so a = [3, 4, 6] and b = [2, 2, 3]; * choose the second gift and eat one candy from it, so a = [3, 3, 6] and b = [2, 2, 3]; * choose the third gift and eat one candy and one orange from it, so a = [3, 3, 5] and b = [2, 2, 2]; * choose the third gift and eat one candy from it, so a = [3, 3, 4] and b = [2, 2, 2]; * choose the third gift and eat one candy from it, so a = [3, 3, 3] and b = [2, 2, 2]. Submitted Solution: ``` t=int(input()) for i in range(t): n=int(input()) l1=list(map(int,input().split())) l2=list(map(int,input().split())) x=min(l1) y=min(l2) move=0 for j in range(n): while(l1[j]!=x and l2[j]!=y): l1[j]-=1 l2[j]-=1 move+=1 if(l1[j]!=x): if(x==1): move+=(l1[j]-1) break move+=(l1[j]-x) if(l2[j]!=y): if(y==1): move+=(l2[j]-1) break move+=(l2[j]-y) print(move) ```
instruction
0
41,446
9
82,892
No
output
1
41,446
9
82,893
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have n gifts and you want to give all of them to children. Of course, you don't want to offend anyone, so all gifts should be equal between each other. The i-th gift consists of a_i candies and b_i oranges. During one move, you can choose some gift 1 ≤ i ≤ n and do one of the following operations: * eat exactly one candy from this gift (decrease a_i by one); * eat exactly one orange from this gift (decrease b_i by one); * eat exactly one candy and exactly one orange from this gift (decrease both a_i and b_i by one). Of course, you can not eat a candy or orange if it's not present in the gift (so neither a_i nor b_i can become less than zero). As said above, all gifts should be equal. This means that after some sequence of moves the following two conditions should be satisfied: a_1 = a_2 = ... = a_n and b_1 = b_2 = ... = b_n (and a_i equals b_i is not necessary). Your task is to find the minimum number of moves required to equalize all the given gifts. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow. The first line of the test case contains one integer n (1 ≤ n ≤ 50) — the number of gifts. The second line of the test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9), where a_i is the number of candies in the i-th gift. The third line of the test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9), where b_i is the number of oranges in the i-th gift. Output For each test case, print one integer: the minimum number of moves required to equalize all the given gifts. Example Input 5 3 3 5 6 3 2 3 5 1 2 3 4 5 5 4 3 2 1 3 1 1 1 2 2 2 6 1 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1 1 1 1 3 10 12 8 7 5 4 Output 6 16 0 4999999995 7 Note In the first test case of the example, we can perform the following sequence of moves: * choose the first gift and eat one orange from it, so a = [3, 5, 6] and b = [2, 2, 3]; * choose the second gift and eat one candy from it, so a = [3, 4, 6] and b = [2, 2, 3]; * choose the second gift and eat one candy from it, so a = [3, 3, 6] and b = [2, 2, 3]; * choose the third gift and eat one candy and one orange from it, so a = [3, 3, 5] and b = [2, 2, 2]; * choose the third gift and eat one candy from it, so a = [3, 3, 4] and b = [2, 2, 2]; * choose the third gift and eat one candy from it, so a = [3, 3, 3] and b = [2, 2, 2]. Submitted Solution: ``` t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) if n == 1: print(0) break count = 0 for j in range(n): count += max(a[j] - min(a), b[j] - min(b)) print(count) ```
instruction
0
41,447
9
82,894
No
output
1
41,447
9
82,895
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have n gifts and you want to give all of them to children. Of course, you don't want to offend anyone, so all gifts should be equal between each other. The i-th gift consists of a_i candies and b_i oranges. During one move, you can choose some gift 1 ≤ i ≤ n and do one of the following operations: * eat exactly one candy from this gift (decrease a_i by one); * eat exactly one orange from this gift (decrease b_i by one); * eat exactly one candy and exactly one orange from this gift (decrease both a_i and b_i by one). Of course, you can not eat a candy or orange if it's not present in the gift (so neither a_i nor b_i can become less than zero). As said above, all gifts should be equal. This means that after some sequence of moves the following two conditions should be satisfied: a_1 = a_2 = ... = a_n and b_1 = b_2 = ... = b_n (and a_i equals b_i is not necessary). Your task is to find the minimum number of moves required to equalize all the given gifts. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow. The first line of the test case contains one integer n (1 ≤ n ≤ 50) — the number of gifts. The second line of the test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9), where a_i is the number of candies in the i-th gift. The third line of the test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9), where b_i is the number of oranges in the i-th gift. Output For each test case, print one integer: the minimum number of moves required to equalize all the given gifts. Example Input 5 3 3 5 6 3 2 3 5 1 2 3 4 5 5 4 3 2 1 3 1 1 1 2 2 2 6 1 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1 1 1 1 3 10 12 8 7 5 4 Output 6 16 0 4999999995 7 Note In the first test case of the example, we can perform the following sequence of moves: * choose the first gift and eat one orange from it, so a = [3, 5, 6] and b = [2, 2, 3]; * choose the second gift and eat one candy from it, so a = [3, 4, 6] and b = [2, 2, 3]; * choose the second gift and eat one candy from it, so a = [3, 3, 6] and b = [2, 2, 3]; * choose the third gift and eat one candy and one orange from it, so a = [3, 3, 5] and b = [2, 2, 2]; * choose the third gift and eat one candy from it, so a = [3, 3, 4] and b = [2, 2, 2]; * choose the third gift and eat one candy from it, so a = [3, 3, 3] and b = [2, 2, 2]. Submitted Solution: ``` def main(): t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) a_min = min(a) b_min = max(b) count = 0 for i in range(n): count += max(a[i]-a_min, b[i]-b_min) print(count) if __name__ == "__main__": main() ''' 3 5 6 => 3 5 6 => 3 2 3 => 2 3 3 => 2 3 1 2 ''' ```
instruction
0
41,448
9
82,896
No
output
1
41,448
9
82,897
Provide tags and a correct Python 3 solution for this coding contest problem. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector.
instruction
0
41,784
9
83,568
Tags: brute force, implementation Correct Solution: ``` #n,k = map(int, input().strip().split(' ')) n=int(input()) lst = list(map(int, input().strip().split(' '))) if n==1: print(lst[0]) elif n==2: print(abs(lst[1]-lst[0])) else: s=360 m=360 lst=lst*2 for i in range(n): p=0 for j in range(i,i+n-1): p+=lst[j] if abs(s-2*p)<m: m=abs(s-2*p) print(m) ```
output
1
41,784
9
83,569
Provide tags and a correct Python 3 solution for this coding contest problem. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector.
instruction
0
41,785
9
83,570
Tags: brute force, implementation Correct Solution: ``` n=int(input()) a=list(map(int,input().split())) print(2*min(abs(180-sum(a[l:r])) for l in range(n) for r in range(l,n))) ```
output
1
41,785
9
83,571
Provide tags and a correct Python 3 solution for this coding contest problem. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector.
instruction
0
41,786
9
83,572
Tags: brute force, implementation Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) maxv = 0 minv = 360 for i in range(0, n): sum = 0 for j in range(i, n): sum = sum + a[j] if(sum > maxv and sum <= 180): maxv = sum if(sum < minv and sum >= 180): minv = sum print(min(360 - 2 * maxv, 2 * minv - 360)) ```
output
1
41,786
9
83,573
Provide tags and a correct Python 3 solution for this coding contest problem. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector.
instruction
0
41,787
9
83,574
Tags: brute force, implementation Correct Solution: ``` n = int(input()) l = [int(x) for x in input().split()] ans = 360 for i in range(n): for j in range(i + 1, n): ans = min(ans, abs(180 - sum(l[i:j])) * 2) print(ans) ```
output
1
41,787
9
83,575
Provide tags and a correct Python 3 solution for this coding contest problem. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector.
instruction
0
41,788
9
83,576
Tags: brute force, implementation Correct Solution: ``` n=int(input()) a=list(map(int,input().split())) #a.sort(reverse=True) l=0 ans=360 sum1=0 for k in a: sum1=sum1+k while(sum1>=180): ans=min(ans,2*abs(180-sum1)) sum1=sum1-a[l] l=l+1 ans=min(ans,2*abs(180-sum1)) print(ans) ```
output
1
41,788
9
83,577
Provide tags and a correct Python 3 solution for this coding contest problem. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector.
instruction
0
41,789
9
83,578
Tags: brute force, implementation Correct Solution: ``` import math a = int(input()) b = list(map(int, input().split())) e = 361 if b[0] == 360: print(360) else: for c in range(a - 1): for d in range(a - 1): if math.fabs(180 - sum(b[c: -(a - 1 - d)])) * 2 < e: e = math.fabs(180 - sum(b[c: -(a - 1 - d)])) * 2 print(int(e)) ```
output
1
41,789
9
83,579
Provide tags and a correct Python 3 solution for this coding contest problem. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector.
instruction
0
41,790
9
83,580
Tags: brute force, implementation Correct Solution: ``` n = int(input()) best = 360 tab = list(map(int, input().split())) pre_sum = [0] for i in range(1, len(tab) + 1): pre_sum += [tab[i - 1] + pre_sum[-1]] for i in range(n + 1): for j in range(i, n + 1): best = min([best, 2 * abs(180 - (pre_sum[j] - pre_sum[i - 1]))]) print(best); ```
output
1
41,790
9
83,581
Provide tags and a correct Python 3 solution for this coding contest problem. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector.
instruction
0
41,791
9
83,582
Tags: brute force, implementation Correct Solution: ``` n = int(input()) l = list(map(int, input().split())) s = [0] r_s = [0] for i in range(n): s.append(s[-1] + l[i]) r_s.append(r_s[-1] + l[n-1-i]) m = float("inf") for right_end in range(n): for left_end in range(n-right_end+1): if abs(s[left_end] + r_s[right_end] - (r_s[-left_end-1] - r_s[right_end])) < m: m = abs(s[left_end] + r_s[right_end] - (r_s[-left_end-1] - r_s[right_end])) print(m) ```
output
1
41,791
9
83,583
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector. Submitted Solution: ``` n=int(input()) a=list(map(int,input().split())) ans=360 for i in range(n): for j in range(i,n): ans=min(ans,abs(180-sum(a[i:j]))*2) print(ans) ```
instruction
0
41,792
9
83,584
Yes
output
1
41,792
9
83,585
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector. Submitted Solution: ``` n = int(input()) a = list(map(int, input().split())) delta = sum(a) for i in range(len(a)): for j in range(len(a)): if delta == 0: break if delta > abs(sum(a[j:]) + sum(a[:i]) - sum(a[i:j])): delta = abs(sum(a[j:]) + sum(a[:i]) - sum(a[i:j])) print(delta) ```
instruction
0
41,793
9
83,586
Yes
output
1
41,793
9
83,587
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector. Submitted Solution: ``` z,zz,dgraphs=input,lambda:list(map(int,z().split())),{} from string import * from collections import * from queue import * from sys import * from collections import * from math import * from heapq import * from itertools import * from bisect import * from collections import Counter as cc from math import factorial as f def lcd(xnum1,xnum2):return (xnum1*xnum2//gcd(xnum1,xnum2)) def prime(x): p=ceil(x**.5)+1 for i in range(2,p): if x%i==0 and x!=2:return 0 return 1 def dfs(u,visit,graph): visit[u]=True for i in graph[u]: if not visit[i]: dfs(i,visit,graph) ################################################################################ """ led=(6,2,5,5,4,5,6,3,7,6) vowel={'a':0,'e':0,'i':0,'o':0,'u':0} color4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ] """ ###########################---START-CODING---#################################### n=int(z()) ll=zz() lx=[360] for l in range(n): for r in range(l+1,n+1): ans = abs(2 * sum(ll[l:r]) - 360) lx.append(ans) print(min(lx)) ```
instruction
0
41,794
9
83,588
Yes
output
1
41,794
9
83,589
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector. Submitted Solution: ``` import math import sys import getpass def ria(): return [int(i) for i in input().split()] files = True if getpass.getuser().lower() == 'frohenk' and files: sys.stdin = open('test.in') #sys.stdout = open('test.out', 'w') n=ria()[0] ar=ria() suma=sum(ar) ar+=ar mini=1000 for i in range(n): for j in range(i,i+n+1): #print() sums = sum(ar[i:j]) cura = abs((suma - sums) - sums) #print(cura,ar[i:j]) mini=min(mini, cura) print(mini) sys.stdout.close() ```
instruction
0
41,795
9
83,590
Yes
output
1
41,795
9
83,591
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector. Submitted Solution: ``` n=int(input()) l=list(map(int,input().split())) l=sorted(l) a=360 for i in range(n) : for j in range(i+1,n) : a=min(a,abs(180-sum(l[i:j]))) print(a) ```
instruction
0
41,796
9
83,592
No
output
1
41,796
9
83,593
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector. Submitted Solution: ``` g=int(input()) l=input().split(" ") for i in range(g): l[i]=int(l[i]) if(g==1): print(l[0]) else: a=max(l) sum=a diff=abs(180-a) if(diff==0): print(0) else: l.remove(a) for i in l: if(abs(180-(a+i))<diff): a=a+i sum=a diff=abs((180-(a+i))) print(abs(360-sum*2)) ```
instruction
0
41,797
9
83,594
No
output
1
41,797
9
83,595
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector. Submitted Solution: ``` n = int(input()) l = input().split() s = 0 s1 = 0 a = list(map(int, l)) f = False lv = [] for m in a[1:n]: s += m if n % 2 == 0: for u in range(n - 1): if (a[u] + a[u + 1] == 180 and f == False) or (a[u] + a[u - 1] == 180 and f == False): print(0) f = True if f == False: for i in range(n - 1): s1 += a[i] print(abs(s1 - a[-1])) if n % 2 == 1: for i in range(n - 1): s1 += a[i] print(abs(s1 - a[-1])) ```
instruction
0
41,798
9
83,596
No
output
1
41,798
9
83,597
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to ai. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty. Input The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut. The second line contains n integers ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360. Output Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya. Examples Input 4 90 90 90 90 Output 0 Input 3 100 100 160 Output 40 Input 1 360 Output 360 Input 4 170 30 150 10 Output 0 Note In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0. In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360. In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0. Picture explaning fourth sample: <image> Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector. Submitted Solution: ``` n = eval(input()) arr = [] arr = [int(x) for x in input().split()] arr.sort() while arr[0] == 0: arr.pop(0) if len(arr) > 1: first = arr.pop() second = arr.pop() while len(arr) > 0: if len(arr) == 1: second += arr.pop() elif len(arr) > 1 and first == second: first += arr.pop(0) second += arr.pop(0) elif first > second: while first > second and len(arr) > 0: second += arr.pop() elif second > first: while second > first and len(arr) > 0: first += arr.pop() print(abs(first - second)) else: print (arr.pop()) ```
instruction
0
41,799
9
83,598
No
output
1
41,799
9
83,599
Provide a correct Python 3 solution for this coding contest problem. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016
instruction
0
42,704
9
85,408
"Correct Solution: ``` N, K = [int(_) for _ in input().split()] TD = [[int(_) for _ in input().split()] for i in range(N)] # print(TD) xs = sorted(TD, key=lambda x:-x[1]) #print(xs) baset = 0 ts = set() ds = [] for t, d in xs[:K]: baset += d if not t in ts: ts.add(t) else: ds.append(d) result = baset + len(ts)**2 r = result for t, d in xs[K:]: if not ds: break if t not in ts: r += 2*len(ts) + 1 r += d - ds.pop() ts.add(t) result = max(r,result) print(result) ```
output
1
42,704
9
85,409
Provide a correct Python 3 solution for this coding contest problem. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016
instruction
0
42,705
9
85,410
"Correct Solution: ``` N,K=map(int,input().split()) l=[] # 寿司リスト。ただし,「おいしさ」を第1要素にする m=[] # 寿司タプルをそのまま入れる s=set() for i in range(N): t,d=map(int,input().split()) l.append((d,t)) l.sort(reverse=True) ans=K**2 t=0 # 既に食べたことのある種類の寿司を更に食べた回数 i=0 # l内を走査する際の添字 j=0 # m内を操作する際の添え字 for _ in range(K): # _番目に食べる寿司について while i<N and l[i][1] in s: m.append(l[i]) # そのままmに追加する i+=1 # lの先頭の要素を削除せず, if (i<N and (m and j<len(m)) and l[i][0]>=m[j][0]-(2*K-1-2*t)) or (not m or j>=len(m)): ans+=l[i][0] s.add(l[i][1]) i+=1 else: ans+=m[j][0]-(2*K-1-2*t) j+=1 t+=1 print(ans) ```
output
1
42,705
9
85,411
Provide a correct Python 3 solution for this coding contest problem. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016
instruction
0
42,706
9
85,412
"Correct Solution: ``` import heapq from operator import itemgetter n, k = map(int, input().split()) sushi = [tuple(map(int, input().split())) for _ in range(n)] sushi.sort(key=itemgetter(1), reverse=True) que = [] kind = set() res = 0 for t, d in sushi[:k]: if t in kind: heapq.heappush(que, d) else: kind.add(t) res += d res += len(kind)**2 val = res for t, d in sushi[k:]: if not que: break if t in kind: continue val += -heapq.heappop(que) + d + len(kind)*2 + 1 kind.add(t) res = max(res, val) print(res) ```
output
1
42,706
9
85,413
Provide a correct Python 3 solution for this coding contest problem. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016
instruction
0
42,707
9
85,414
"Correct Solution: ``` import heapq as h;I=lambda:list(map(int,input().split()));n,k=I();z=[i*2+1for i in range(n)];s=sorted([I()for _ in[0]*n],key=lambda x:-x[1]);q=[];v=A=0;l=[0]*-~n for a,b in s[:k]: if l[a]:h.heappush(q,b) else:A+=z[v];v+=1 l[a]=1;A+=b T=A for a,b in s[k:]: if l[a]^1and q:l[a]=1;T+=b+z[v]-h.heappop(q);v+=1;A=max(A,T) print(A) ```
output
1
42,707
9
85,415
Provide a correct Python 3 solution for this coding contest problem. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016
instruction
0
42,708
9
85,416
"Correct Solution: ``` N, K = map(int, input().split()) td = [list(map(int, input().split())) for _ in range(N)] td.sort(key=lambda x: -x[1]) q = [] v = set() sd = 0 for t, d in td[:K]: sd += d if t in v: q.append(d) v.add(t) ans = len(v) ** 2 + sd for t, d in td[K:]: if 0 >= len(q): break if t in v: continue v.add(t) md = q.pop() sd = sd - md + d tans = len(v) ** 2 + sd ans = max(ans, tans) print(ans) ```
output
1
42,708
9
85,417
Provide a correct Python 3 solution for this coding contest problem. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016
instruction
0
42,709
9
85,418
"Correct Solution: ``` N, K = map(int, input().split()) menu_ = [] for i in range(N): t, d = map(int, input().split()) menu_.append((t, d)) menu = sorted(menu_, key = lambda x:x[1], reverse=True) neta = set() duplicates = [] for m in menu[:K]: if m[0] in neta: duplicates.append(m[1]) else: neta.add(m[0]) p = sum([d for (t, d) in menu[:K]]) + len(neta)**2 ans = p for m in menu[K:]: if m[0] not in neta and duplicates: neta.add(m[0]) duplicate = duplicates.pop() p += (m[1] - duplicate) + 2 * len(neta) - 1 #print(ans, p) ans = max(ans, p) print(ans) ```
output
1
42,709
9
85,419
Provide a correct Python 3 solution for this coding contest problem. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016
instruction
0
42,710
9
85,420
"Correct Solution: ``` n,k=map(int,input().split()) TD=[] for i in range(n): t,d=map(int,input().split()) TD.append([t,d]) TD.sort(key=lambda x:x[1],reverse=True) V=set() S=[] ans=0 for t,d in TD[:k]: ans+=d if t in V: S.append(d) else: V.add(t) ans+=len(V)**2 x=ans for t,d in TD[k:]: if S==[]: break if not t in V: x=x-S.pop()+d-len(V)**2+(len(V)+1)**2 V.add(t) ans=max(x,ans) print(ans) ```
output
1
42,710
9
85,421
Provide a correct Python 3 solution for this coding contest problem. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016
instruction
0
42,711
9
85,422
"Correct Solution: ``` n,k=[int(x) for x in input().split()] A=[] for i in range(n): a,b=[int(x) for x in input().split()] A.append([b,a,True]) A.sort(reverse=True) typ=set() for i in range(n): if A[i][1] in typ: A[i][2]=False else: typ.add(A[i][1]) num=0 for j in range(k): if A[j][2]==True: #print(j) num+=1 ans=0 for i in range(k): ans+=A[i][0] ans+=num**2 curr=ans nxt = k lst = k-1 while(True): while(nxt < n and A[nxt][2] == False): nxt += 1 while(lst >= 0 and A[lst][2] == True): lst -= 1 if not(nxt < n and lst >= 0): break curr += A[nxt][0] - A[lst][0] curr += (num+1) ** 2 - num**2 num+=1 nxt+= 1 lst -= 1 ans=max(ans,curr) print(ans) ```
output
1
42,711
9
85,423
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016 Submitted Solution: ``` n,k=map(int, input().split()) a=sorted([list(map(int, input().split())) for i in range(n)], key=lambda x:-x[1]) q=[] ans=0 s=set() for i in range(k): ans+=a[i][1] if a[i][0] in s: q.append(a[i][1]) s.add(a[i][0]) ans+=len(s)**2 k1=k ans1=ans while k1<n and q: if a[k1][0] not in s: ans1=ans1+a[k1][1]-q.pop()-len(s)**2+(len(s)+1)**2 ans=max(ans,ans1) s.add(a[k1][0]) k1+=1 print(ans) ```
instruction
0
42,712
9
85,424
Yes
output
1
42,712
9
85,425
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016 Submitted Solution: ``` n, k = map(int, input().split()) td = sorted([list(map(int, input().split())) for i in range(n)], reverse=True, key=lambda x: x[1]) type = set() L = [] Sum = 0 for x in td[:k]: Sum += x[1] if x[0] not in type: type.add(x[0]) else: L.append(x[1]) L = L[::-1] type_cnt = len(type) ans = Sum + type_cnt ** 2 for x in td[k:]: if len(L)==0:break if x[0] not in type: type.add(x[0]) type_cnt += 1 Sum = Sum - L.pop(0) + x[1] ans = max(ans, Sum + type_cnt ** 2) print(ans) ```
instruction
0
42,713
9
85,426
Yes
output
1
42,713
9
85,427
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016 Submitted Solution: ``` from heapq import heappush, heappop N, K = map(int, input().split()) t, d = ( zip(*(map(int, input().split()) for _ in range(N))) if N else ((), ()) ) # おいしさについて貪欲に寿司を食べたときの満足ポイントを求める # その後、種類ボーナスを1個ずつ増やしたときの満足ポイントをそれぞれ求め、 # それらの最大値を求める S = sorted(zip(d, t), reverse=True) q = [] v = set() s = 0 for D, T in S[:K]: s += D if T in v: heappush(q, D) else: v.add(T) s += len(v)**2 opt = s for D, T in S[K:]: if T not in v and q: z = heappop(q) s += D + 2 * len(v) + 1 - z v.add(T) opt = max(opt, s) ans = opt print(ans) ```
instruction
0
42,714
9
85,428
Yes
output
1
42,714
9
85,429
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016 Submitted Solution: ``` import heapq N,K=map(int,input().split()) L=[] for _ in range(N): (t,d)=map(int,input().split()) heapq.heappush(L,(-d,t)) LL=[] sum=0 used=set() for i in range(K): d,t=heapq.heappop(L) if t in used: heapq.heappush(LL,(-d,t)) used.add(t) sum+=-d ans=len(used)**2+sum while L and LL: d,t=heapq.heappop(L) if t not in used: used.add(t) dd,_=heapq.heappop(LL) sum=sum-dd+(-d) ans=max(ans,len(used)**2+sum) print(ans) ```
instruction
0
42,715
9
85,430
Yes
output
1
42,715
9
85,431
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016 Submitted Solution: ``` from collections import Counter n,k = map(int,input().split()) td = [list(map(int,input().split())) for i in range(n)] td.sort(key = lambda x:x[1],reverse=True) ans = list(range(k)) ansv = sum((td[i][1] for i in range(k))) c = Counter((td[i][0] for i in range(k))) cnt = len(c) ansv += len(c)**2 ptr = k ansls = [ansv] for i in range(k-1,-1,-1): t,d = td[ans[i]] if ptr < n and c[t] > 1: while ptr < n and c[td[ptr][0]] >= 1: ptr += 1 ansv = ansv-d+2*cnt+1+td[ptr][1] c[t] -= 1 c[td[ptr][0]] += 1 cnt += 1 ptr += 1 ansls.append(ansv) print(max(ansls)) ```
instruction
0
42,716
9
85,432
No
output
1
42,716
9
85,433
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016 Submitted Solution: ``` import sys input = sys.stdin.buffer.readline n, k = map(int, input().split()) sushi = [] top = {} for i in range(n): t, d = map(int, input().split()) sushi.append((d, t)) if t not in top: top[t] = d else: top[t] = max(top[t], d) sushi.sort() fixed = {} ate = [] for i in range(k): d, t = sushi.pop() if t not in fixed: fixed[t] = d else: ate.append(d) ate.sort(reverse=True) score = sum(fixed.values()) + sum(ate) + len(fixed) * len(fixed) remain = sorted([(d, t) for t, d in top.items() if t not in fixed]) while remain and ate: d, t = remain.pop() fixed[t] = d ate.pop() s = sum(fixed.values()) + sum(ate) + len(fixed) * len(fixed) score = max(score, s) print(score) ```
instruction
0
42,717
9
85,434
No
output
1
42,717
9
85,435
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016 Submitted Solution: ``` import heapq n, k = map(int, input().split()) sushi = [] for i in range(n): t, d = map(int, input().split()) sushi.append((d, t)) sushi.sort(reverse=True) ans = 0 num_d = 0 num_t = dict() for i in range(k): d, t = sushi[i] num_d += d if not t in num_t: num_t[t] = 1 else: num_t[t] += 1 ans = max(ans, num_d + len(num_t) ** 2) s = sushi[:k] heapq.heapify(s) ns = [(-x, x, y) for x, y in sushi[k:]] heapq.heapify(ns) for i in range(k - 1): if all([i == 1 for i in num_t.values()]): break for j in range(k - 1): d, t = heapq.heappop(s) if num_t[t] > 1: for l in range(n - k): dnm, dn, tn = heapq.heappop(ns) if not tn in num_t: num_t[t] -= 1 num_d -= d num_t[tn] = 1 num_d += dn break break else: heapq.heappush(s, (d, t)) ans = max(ans, num_d + len(num_t) ** 2) print(ans) ```
instruction
0
42,718
9
85,436
No
output
1
42,718
9
85,437
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total deliciousness is the sum of the deliciousness of the pieces you eat. * The variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat. You want to have as much satisfaction as possible. Find this maximum satisfaction. Constraints * 1 \leq K \leq N \leq 10^5 * 1 \leq t_i \leq N * 1 \leq d_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N K t_1 d_1 t_2 d_2 . . . t_N d_N Output Print the maximum satisfaction that you can obtain. Examples Input 5 3 1 9 1 7 2 6 2 5 3 1 Output 26 Input 7 4 1 1 2 1 3 1 4 6 4 5 4 5 4 5 Output 25 Input 6 5 5 1000000000 2 990000000 3 980000000 6 970000000 6 960000000 4 950000000 Output 4900000016 Submitted Solution: ``` import heapq n,k=map(int,input().split()) data=[] for i in range(n): t,d=map(int,input().split()) data.append((-d,t)) data=sorted(data) neta=set() que1=[] que2=[] p,x=0,0 for i in range(k): if data[i][1] in neta: heapq.heappush(que1,data[i]) x-=data[i][0] else: x-=data[i][0] p+=1 neta.add(data[i][1]) for i in range(k,n): if data[i][1]in neta: pass else: heapq.heappush(que2,data[i]) mx=x+p*p while que1: a=heapq.heappop(que1) b=None while que2: b=heapq.heappop(que2) if b[1] not in neta: break b=None if b==None: break x=x+a[0]-b[0] p+=1 neta.add(b[1]) mx=max(mx,x+p*p) print(mx) ```
instruction
0
42,719
9
85,438
No
output
1
42,719
9
85,439
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. problem At the JOI pasta shop, the recommended pasta for lunch and the set menu of freshly squeezed juice are popular. When ordering this set menu, choose one from each of the three pasta and two juices of the day. The price is the total price of pasta and juice minus 50 yen. Given the price of pasta and juice for a day, create a program to find the minimum price for the set menu for that day. output Output the minimum price of the set menu for the day in one line. Example Input 800 700 900 198 330 Output 848 Submitted Solution: ``` N=10000 M=10000 for i in range(3): N=min(N,int(input())) for i in range(2): M=min(M,int(input())) print(N+M-50) ```
instruction
0
42,839
9
85,678
Yes
output
1
42,839
9
85,679
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. problem At the JOI pasta shop, the recommended pasta for lunch and the set menu of freshly squeezed juice are popular. When ordering this set menu, choose one from each of the three pasta and two juices of the day. The price is the total price of pasta and juice minus 50 yen. Given the price of pasta and juice for a day, create a program to find the minimum price for the set menu for that day. output Output the minimum price of the set menu for the day in one line. Example Input 800 700 900 198 330 Output 848 Submitted Solution: ``` a=[] b=[] for i in range(3): a.append(int(input())) a.sort() for j in range(3,5): b.append(int(input())) b.sort() print(a[0]+b[0]-50) ```
instruction
0
42,842
9
85,684
Yes
output
1
42,842
9
85,685
Provide tags and a correct Python 3 solution for this coding contest problem. Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are n drinks in his fridge, the volume fraction of orange juice in the i-th drink equals pi percent. One day Vasya decided to make himself an orange cocktail. He took equal proportions of each of the n drinks and mixed them. Then he wondered, how much orange juice the cocktail has. Find the volume fraction of orange juice in the final drink. Input The first input line contains a single integer n (1 ≤ n ≤ 100) — the number of orange-containing drinks in Vasya's fridge. The second line contains n integers pi (0 ≤ pi ≤ 100) — the volume fraction of orange juice in the i-th drink, in percent. The numbers are separated by a space. Output Print the volume fraction in percent of orange juice in Vasya's cocktail. The answer will be considered correct if the absolute or relative error does not exceed 10 - 4. Examples Input 3 50 50 100 Output 66.666666666667 Input 4 0 25 50 75 Output 37.500000000000 Note Note to the first sample: let's assume that Vasya takes x milliliters of each drink from the fridge. Then the volume of pure juice in the cocktail will equal <image> milliliters. The total cocktail's volume equals 3·x milliliters, so the volume fraction of the juice in the cocktail equals <image>, that is, 66.(6) percent.
instruction
0
44,092
9
88,184
Tags: implementation, math Correct Solution: ``` n = int(input()) a = [int(x) for x in input().split()] print('{:.12f}'.format(sum(a)/n)) ```
output
1
44,092
9
88,185
Provide tags and a correct Python 3 solution for this coding contest problem. Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are n drinks in his fridge, the volume fraction of orange juice in the i-th drink equals pi percent. One day Vasya decided to make himself an orange cocktail. He took equal proportions of each of the n drinks and mixed them. Then he wondered, how much orange juice the cocktail has. Find the volume fraction of orange juice in the final drink. Input The first input line contains a single integer n (1 ≤ n ≤ 100) — the number of orange-containing drinks in Vasya's fridge. The second line contains n integers pi (0 ≤ pi ≤ 100) — the volume fraction of orange juice in the i-th drink, in percent. The numbers are separated by a space. Output Print the volume fraction in percent of orange juice in Vasya's cocktail. The answer will be considered correct if the absolute or relative error does not exceed 10 - 4. Examples Input 3 50 50 100 Output 66.666666666667 Input 4 0 25 50 75 Output 37.500000000000 Note Note to the first sample: let's assume that Vasya takes x milliliters of each drink from the fridge. Then the volume of pure juice in the cocktail will equal <image> milliliters. The total cocktail's volume equals 3·x milliliters, so the volume fraction of the juice in the cocktail equals <image>, that is, 66.(6) percent.
instruction
0
44,093
9
88,186
Tags: implementation, math Correct Solution: ``` n=int(input()) l=[int(x) for x in input().rstrip().split(' ')] x=0 for i in range(n): x=x+(l[i]/100) x=(x/n)*100 print('%.12f'%x) ```
output
1
44,093
9
88,187
Provide tags and a correct Python 3 solution for this coding contest problem. Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are n drinks in his fridge, the volume fraction of orange juice in the i-th drink equals pi percent. One day Vasya decided to make himself an orange cocktail. He took equal proportions of each of the n drinks and mixed them. Then he wondered, how much orange juice the cocktail has. Find the volume fraction of orange juice in the final drink. Input The first input line contains a single integer n (1 ≤ n ≤ 100) — the number of orange-containing drinks in Vasya's fridge. The second line contains n integers pi (0 ≤ pi ≤ 100) — the volume fraction of orange juice in the i-th drink, in percent. The numbers are separated by a space. Output Print the volume fraction in percent of orange juice in Vasya's cocktail. The answer will be considered correct if the absolute or relative error does not exceed 10 - 4. Examples Input 3 50 50 100 Output 66.666666666667 Input 4 0 25 50 75 Output 37.500000000000 Note Note to the first sample: let's assume that Vasya takes x milliliters of each drink from the fridge. Then the volume of pure juice in the cocktail will equal <image> milliliters. The total cocktail's volume equals 3·x milliliters, so the volume fraction of the juice in the cocktail equals <image>, that is, 66.(6) percent.
instruction
0
44,094
9
88,188
Tags: implementation, math Correct Solution: ``` n=int(input()) x=list(map(int,input().split())) tp=0 for i in x: tp+=i/100 tot=(tp/n)*100 print('%.10f'%tot) ```
output
1
44,094
9
88,189
Provide tags and a correct Python 3 solution for this coding contest problem. Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are n drinks in his fridge, the volume fraction of orange juice in the i-th drink equals pi percent. One day Vasya decided to make himself an orange cocktail. He took equal proportions of each of the n drinks and mixed them. Then he wondered, how much orange juice the cocktail has. Find the volume fraction of orange juice in the final drink. Input The first input line contains a single integer n (1 ≤ n ≤ 100) — the number of orange-containing drinks in Vasya's fridge. The second line contains n integers pi (0 ≤ pi ≤ 100) — the volume fraction of orange juice in the i-th drink, in percent. The numbers are separated by a space. Output Print the volume fraction in percent of orange juice in Vasya's cocktail. The answer will be considered correct if the absolute or relative error does not exceed 10 - 4. Examples Input 3 50 50 100 Output 66.666666666667 Input 4 0 25 50 75 Output 37.500000000000 Note Note to the first sample: let's assume that Vasya takes x milliliters of each drink from the fridge. Then the volume of pure juice in the cocktail will equal <image> milliliters. The total cocktail's volume equals 3·x milliliters, so the volume fraction of the juice in the cocktail equals <image>, that is, 66.(6) percent.
instruction
0
44,095
9
88,190
Tags: implementation, math Correct Solution: ``` a = int(input()) l = list(map(int, input().split())) print(round(sum(l) / a, 6)) ```
output
1
44,095
9
88,191
Provide tags and a correct Python 3 solution for this coding contest problem. Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are n drinks in his fridge, the volume fraction of orange juice in the i-th drink equals pi percent. One day Vasya decided to make himself an orange cocktail. He took equal proportions of each of the n drinks and mixed them. Then he wondered, how much orange juice the cocktail has. Find the volume fraction of orange juice in the final drink. Input The first input line contains a single integer n (1 ≤ n ≤ 100) — the number of orange-containing drinks in Vasya's fridge. The second line contains n integers pi (0 ≤ pi ≤ 100) — the volume fraction of orange juice in the i-th drink, in percent. The numbers are separated by a space. Output Print the volume fraction in percent of orange juice in Vasya's cocktail. The answer will be considered correct if the absolute or relative error does not exceed 10 - 4. Examples Input 3 50 50 100 Output 66.666666666667 Input 4 0 25 50 75 Output 37.500000000000 Note Note to the first sample: let's assume that Vasya takes x milliliters of each drink from the fridge. Then the volume of pure juice in the cocktail will equal <image> milliliters. The total cocktail's volume equals 3·x milliliters, so the volume fraction of the juice in the cocktail equals <image>, that is, 66.(6) percent.
instruction
0
44,096
9
88,192
Tags: implementation, math Correct Solution: ``` n = int(input()) li = list(map(int, input().split())) avg = sum(li) / (len(li) * 100) print('{0:.12f}'.format(round(avg * 100, 12))) ```
output
1
44,096
9
88,193
Provide tags and a correct Python 3 solution for this coding contest problem. Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are n drinks in his fridge, the volume fraction of orange juice in the i-th drink equals pi percent. One day Vasya decided to make himself an orange cocktail. He took equal proportions of each of the n drinks and mixed them. Then he wondered, how much orange juice the cocktail has. Find the volume fraction of orange juice in the final drink. Input The first input line contains a single integer n (1 ≤ n ≤ 100) — the number of orange-containing drinks in Vasya's fridge. The second line contains n integers pi (0 ≤ pi ≤ 100) — the volume fraction of orange juice in the i-th drink, in percent. The numbers are separated by a space. Output Print the volume fraction in percent of orange juice in Vasya's cocktail. The answer will be considered correct if the absolute or relative error does not exceed 10 - 4. Examples Input 3 50 50 100 Output 66.666666666667 Input 4 0 25 50 75 Output 37.500000000000 Note Note to the first sample: let's assume that Vasya takes x milliliters of each drink from the fridge. Then the volume of pure juice in the cocktail will equal <image> milliliters. The total cocktail's volume equals 3·x milliliters, so the volume fraction of the juice in the cocktail equals <image>, that is, 66.(6) percent.
instruction
0
44,097
9
88,194
Tags: implementation, math Correct Solution: ``` n=input() n=int(n) a=input().split() s=0 for i in range (0,n): s=s+int(a[i]) print(format(s/n,'.5f')) ```
output
1
44,097
9
88,195
Provide tags and a correct Python 3 solution for this coding contest problem. Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are n drinks in his fridge, the volume fraction of orange juice in the i-th drink equals pi percent. One day Vasya decided to make himself an orange cocktail. He took equal proportions of each of the n drinks and mixed them. Then he wondered, how much orange juice the cocktail has. Find the volume fraction of orange juice in the final drink. Input The first input line contains a single integer n (1 ≤ n ≤ 100) — the number of orange-containing drinks in Vasya's fridge. The second line contains n integers pi (0 ≤ pi ≤ 100) — the volume fraction of orange juice in the i-th drink, in percent. The numbers are separated by a space. Output Print the volume fraction in percent of orange juice in Vasya's cocktail. The answer will be considered correct if the absolute or relative error does not exceed 10 - 4. Examples Input 3 50 50 100 Output 66.666666666667 Input 4 0 25 50 75 Output 37.500000000000 Note Note to the first sample: let's assume that Vasya takes x milliliters of each drink from the fridge. Then the volume of pure juice in the cocktail will equal <image> milliliters. The total cocktail's volume equals 3·x milliliters, so the volume fraction of the juice in the cocktail equals <image>, that is, 66.(6) percent.
instruction
0
44,098
9
88,196
Tags: implementation, math Correct Solution: ``` n=int(input()) a=[int(x) for x in input().split()] print(sum(a)/n) ```
output
1
44,098
9
88,197
Provide tags and a correct Python 3 solution for this coding contest problem. Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are n drinks in his fridge, the volume fraction of orange juice in the i-th drink equals pi percent. One day Vasya decided to make himself an orange cocktail. He took equal proportions of each of the n drinks and mixed them. Then he wondered, how much orange juice the cocktail has. Find the volume fraction of orange juice in the final drink. Input The first input line contains a single integer n (1 ≤ n ≤ 100) — the number of orange-containing drinks in Vasya's fridge. The second line contains n integers pi (0 ≤ pi ≤ 100) — the volume fraction of orange juice in the i-th drink, in percent. The numbers are separated by a space. Output Print the volume fraction in percent of orange juice in Vasya's cocktail. The answer will be considered correct if the absolute or relative error does not exceed 10 - 4. Examples Input 3 50 50 100 Output 66.666666666667 Input 4 0 25 50 75 Output 37.500000000000 Note Note to the first sample: let's assume that Vasya takes x milliliters of each drink from the fridge. Then the volume of pure juice in the cocktail will equal <image> milliliters. The total cocktail's volume equals 3·x milliliters, so the volume fraction of the juice in the cocktail equals <image>, that is, 66.(6) percent.
instruction
0
44,099
9
88,198
Tags: implementation, math Correct Solution: ``` n=int(input()) arr=list(map(int,input().split())) s=sum(arr) print(s/n) ```
output
1
44,099
9
88,199
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are n drinks in his fridge, the volume fraction of orange juice in the i-th drink equals pi percent. One day Vasya decided to make himself an orange cocktail. He took equal proportions of each of the n drinks and mixed them. Then he wondered, how much orange juice the cocktail has. Find the volume fraction of orange juice in the final drink. Input The first input line contains a single integer n (1 ≤ n ≤ 100) — the number of orange-containing drinks in Vasya's fridge. The second line contains n integers pi (0 ≤ pi ≤ 100) — the volume fraction of orange juice in the i-th drink, in percent. The numbers are separated by a space. Output Print the volume fraction in percent of orange juice in Vasya's cocktail. The answer will be considered correct if the absolute or relative error does not exceed 10 - 4. Examples Input 3 50 50 100 Output 66.666666666667 Input 4 0 25 50 75 Output 37.500000000000 Note Note to the first sample: let's assume that Vasya takes x milliliters of each drink from the fridge. Then the volume of pure juice in the cocktail will equal <image> milliliters. The total cocktail's volume equals 3·x milliliters, so the volume fraction of the juice in the cocktail equals <image>, that is, 66.(6) percent. Submitted Solution: ``` n = int(input()) per = list(map(int, input().rstrip().split())) print(sum(per) / n) ```
instruction
0
44,100
9
88,200
Yes
output
1
44,100
9
88,201