message
stringlengths
2
30.5k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
237
109k
cluster
float64
10
10
__index_level_0__
int64
474
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland). You are the royal treasurer, which needs to count the minimum charges of the kingdom on the king's present. The king can only give money, he hasn't a power to take away them. Input The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen. Output In the only line print the integer S — the minimum number of burles which are had to spend. Examples Input 5 0 1 2 3 4 Output 10 Input 5 1 1 0 1 1 Output 1 Input 3 1 3 1 Output 4 Input 1 12 Output 0 Note In the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4. In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the third citizens to make the welfare of citizens equal 3. In the fourth example it is possible to give nothing to everyone because all citizens have 12 burles. Submitted Solution: ``` num = int(input()) l = input().split(" ") m = max(l) s = 0 for i in range(num) : if (int(l[i]) != m) : s += int(m) - int(l[i]) print(s) ```
instruction
0
73,821
10
147,642
No
output
1
73,821
10
147,643
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland). You are the royal treasurer, which needs to count the minimum charges of the kingdom on the king's present. The king can only give money, he hasn't a power to take away them. Input The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen. Output In the only line print the integer S — the minimum number of burles which are had to spend. Examples Input 5 0 1 2 3 4 Output 10 Input 5 1 1 0 1 1 Output 1 Input 3 1 3 1 Output 4 Input 1 12 Output 0 Note In the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4. In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the third citizens to make the welfare of citizens equal 3. In the fourth example it is possible to give nothing to everyone because all citizens have 12 burles. Submitted Solution: ``` num_citizens = int(input()) welfares = [int(a) for a in input().strip().split()] welfares.sort() maximum = welfares[-1] total = maximum * num_citizens print(sum(welfares) - total) ```
instruction
0
73,822
10
147,644
No
output
1
73,822
10
147,645
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland). You are the royal treasurer, which needs to count the minimum charges of the kingdom on the king's present. The king can only give money, he hasn't a power to take away them. Input The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen. Output In the only line print the integer S — the minimum number of burles which are had to spend. Examples Input 5 0 1 2 3 4 Output 10 Input 5 1 1 0 1 1 Output 1 Input 3 1 3 1 Output 4 Input 1 12 Output 0 Note In the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4. In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the third citizens to make the welfare of citizens equal 3. In the fourth example it is possible to give nothing to everyone because all citizens have 12 burles. Submitted Solution: ``` n = int(input()) a = list(map(int, input().split())) S = 0 if len(a) == 1: S = a[0] else: max_a = max(a) for i in range(n): diff = max_a - a[i] if diff > 0: S += diff print (S) ```
instruction
0
73,823
10
147,646
No
output
1
73,823
10
147,647
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0
instruction
0
73,992
10
147,984
"Correct Solution: ``` a,b=map(int,input().split()) if 5<a<13:print(b//2) elif 12<a:print(b) else:print(0) ```
output
1
73,992
10
147,985
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0
instruction
0
73,993
10
147,986
"Correct Solution: ``` a, b = [int(x) for x in input().split()] if a < 6: b = 0 elif a < 13: b //= 2 print(b) ```
output
1
73,993
10
147,987
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0
instruction
0
73,994
10
147,988
"Correct Solution: ``` a, b=map(int, input().split()) if(a >=6): print(b if a>=13 else b//2) else: print(0) ```
output
1
73,994
10
147,989
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0
instruction
0
73,995
10
147,990
"Correct Solution: ``` print((lambda a, b: b if a > 12 else b // 2 if a > 5 else 0)(*map(int, input().split()))) ```
output
1
73,995
10
147,991
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0
instruction
0
73,996
10
147,992
"Correct Solution: ``` a,b=list((map(int,input().split())));print(b) if a>12 else print(int(b/2*bool(int(a/6)))) ```
output
1
73,996
10
147,993
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0
instruction
0
73,997
10
147,994
"Correct Solution: ``` A,B=map(int,input().split());print(B if A>=13 else B//2 if 12 >= A >= 6 else 0) ```
output
1
73,997
10
147,995
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0
instruction
0
73,998
10
147,996
"Correct Solution: ``` x , y = map(int, input().split()) ans = y if x >= 13 else y//2 if 6<=x<=12 else 0 print(ans) ```
output
1
73,998
10
147,997
Provide a correct Python 3 solution for this coding contest problem. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0
instruction
0
73,999
10
147,998
"Correct Solution: ``` a,b=map(int,input().split()) if(6<=a<=12): b//=2 elif(a<6): b=0 print(b) ```
output
1
73,999
10
147,999
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0 Submitted Solution: ``` a,b=map(int,input().split()) print(b if a>=13 else (a>=6)*b//2) ```
instruction
0
74,000
10
148,000
Yes
output
1
74,000
10
148,001
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0 Submitted Solution: ``` a,b=map(int, input().split()) print(b if a > 12 else int(b/2) if 6 <= a <= 12 else 0) ```
instruction
0
74,001
10
148,002
Yes
output
1
74,001
10
148,003
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0 Submitted Solution: ``` A,B=map(int, input().split()) print(B if A>=13 else (B//2 if A>=6 else 0)) ```
instruction
0
74,002
10
148,004
Yes
output
1
74,002
10
148,005
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0 Submitted Solution: ``` a,b=map(int,input().split()) print(b if a>12 else 0 if a<6 else b//2) ```
instruction
0
74,003
10
148,006
Yes
output
1
74,003
10
148,007
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0 Submitted Solution: ``` A=int(input()) B=int(input()) if A>=13: print(B) elif A>=6: print(B/2) else : print (0) ```
instruction
0
74,004
10
148,008
No
output
1
74,004
10
148,009
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0 Submitted Solution: ``` N = int(input()) I = int(input()) if I <= 13: print(N) elif: 6 <= I <=12: print(N/2) elif: I <= 5 print("0") ```
instruction
0
74,005
10
148,010
No
output
1
74,005
10
148,011
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0 Submitted Solution: ``` A,B=map(int,input().split()) if A>=13: print(B) elif A>5: print(B/2) else: print(0) ```
instruction
0
74,006
10
148,012
No
output
1
74,006
10
148,013
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi. Constraints * 0 ≤ A ≤ 100 * 2 ≤ B ≤ 1000 * B is an even number. Input Input is given from Standard Input in the following format: A B Output Print the cost of the Ferris wheel for Takahashi. Examples Input 30 100 Output 100 Input 12 100 Output 50 Input 0 100 Output 0 Submitted Solution: ``` a,b = map(int,input().split()) if a >= 13: print(b) if 6<=a & a<=12: print(b/2) if a<=5: print(0) ```
instruction
0
74,007
10
148,014
No
output
1
74,007
10
148,015
Provide tags and a correct Python 3 solution for this coding contest problem. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52.
instruction
0
74,369
10
148,738
Tags: implementation, math Correct Solution: ``` for _ in range(int(input())): n,c0,c1,h=map(int,input().split()) s=input() s0=s.count("0") s1=s.count("1") a1=(c0*s0)+(c1*s1) a2=(c0*s0)+(s1*(c0+h)) a3=(c1*s1)+(s0*(c1+h)) ans=min(a1,a2,a3) print(ans) ```
output
1
74,369
10
148,739
Provide tags and a correct Python 3 solution for this coding contest problem. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52.
instruction
0
74,370
10
148,740
Tags: implementation, math Correct Solution: ``` for _ in range(int(input())): n,c0,c1,h=map(int,input().split()) s=input() if c0 < c1: if (h+c0) >= c1: flag=False else: c1=h+c0 elif c0 > c1: if (h+c1) >= c0: flag=False else: c0=h+c1 else: pass ans=0 for i in s: if(i=='0'): ans=ans+c0 else: ans=ans+c1 print(ans) ```
output
1
74,370
10
148,741
Provide tags and a correct Python 3 solution for this coding contest problem. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52.
instruction
0
74,371
10
148,742
Tags: implementation, math Correct Solution: ``` t = int(input()) for j in range(t): n, c0, c1, h = map(int, input().split()) b = input() summ = 0 if c0 > c1 + h: for i in range(n): if b[i] == '0': summ += c1 summ += h else: summ += c1 elif c1 > c0 + h: for i in range(n): if b[i] == '1': summ += c0 summ += h else: summ += c0 else: for i in range(n): if b[i] == '0': summ += c0 else: summ += c1 print(summ) ```
output
1
74,371
10
148,743
Provide tags and a correct Python 3 solution for this coding contest problem. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52.
instruction
0
74,372
10
148,744
Tags: implementation, math Correct Solution: ``` for _ in range(int(input())): a,b,c,d = map(int,input().split()) n = input() ans = 0 for i in n: if i=="0": ans+=min(d+c,b) elif i=="1": ans+=min(d+b,c) print(ans) ```
output
1
74,372
10
148,745
Provide tags and a correct Python 3 solution for this coding contest problem. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52.
instruction
0
74,373
10
148,746
Tags: implementation, math Correct Solution: ``` for t in range(int(input())): n,c0,c1,h=map(int,input().split()) s=input() ze=s.count("0") on=s.count("1") noch=ze*c0+on*c1 ch1=ze*(h)+n*c1 ch2=on*h+n*c0 print(min(noch,ch1,ch2)) ```
output
1
74,373
10
148,747
Provide tags and a correct Python 3 solution for this coding contest problem. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52.
instruction
0
74,374
10
148,748
Tags: implementation, math Correct Solution: ``` t = int(input()) for _ in range(t): n, c0, c1, h = list(map(int, input().split())) s = input() cost = 0 if c1 == c0: cost += c0 * n elif c0 > c1: cost += c1 * s.count('1') if c0 > h+c1: cost += (h+c1)*s.count('0') else: cost+= (c0)*s.count('0') else: cost+=c0*s.count('0') if c1 > h+c0: cost += (h+c0)*s.count('1') else: cost+= (c1)*s.count('1') print(cost) ```
output
1
74,374
10
148,749
Provide tags and a correct Python 3 solution for this coding contest problem. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52.
instruction
0
74,375
10
148,750
Tags: implementation, math Correct Solution: ``` for t in range(int(input())): n, c0, c1, h = map(int, input().split()) s = input() _0 = s.count('0') _1 = s.count('1') print(min(c0 * _0 + c1 * _1, c0 * len(s) + h * _1, c1 * len(s) + h * _0)) ```
output
1
74,375
10
148,751
Provide tags and a correct Python 3 solution for this coding contest problem. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52.
instruction
0
74,376
10
148,752
Tags: implementation, math Correct Solution: ``` n=int(input()) for i in range(n): n1,c0,c1,h=map(int,input().split()) s=input() cnt0=s.count('0') cnt1=s.count('1') if c0==c1: print(c0*n1) elif c0<c1: s0=(c0*n1)+(h*cnt1) s00=(c0*cnt0)+(c1*cnt1) print(min(s0,s00)) elif c0>c1: s1=(c1*n1)+(h*cnt0) s11=(c1*cnt1)+(c0*cnt0) print(min(s1,s11)) ```
output
1
74,376
10
148,753
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52. Submitted Solution: ``` from collections import Counter def fun(n,c0,c1,h,st): dct=Counter(st) # h for each charecter change # c0 for buying 0 # c1 for buying 1 count1= dct.get('1') if dct.get('1')!=None else 0 count0= dct.get('0') if dct.get('0')!=None else 0 if(c0>c1): print(min(((count1+count0)*c1 + count0*h),(count1*c1+count0*c0))) else: print(min(((count1+count0)*c0 + count1*h),(count1*c1+count0*c0))) T= int(input()) for i in range(T): # t= int(input()) n,c0,c1,h= list(map(int,input().split())) st=input() fun(n,c0,c1,h,st) ```
instruction
0
74,377
10
148,754
Yes
output
1
74,377
10
148,755
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52. Submitted Solution: ``` t=int(input()) for _ in range(t): n,c0,c1,h=list(map(int,input().split())) s=input() n0=s.count('0') n1=n-n0 if abs(c0-c1)<=h: print(n0*c0+n1*c1) else: if c0>c1: print(n*c1+n0*h) else: print(n*c0+n1*h) ```
instruction
0
74,378
10
148,756
Yes
output
1
74,378
10
148,757
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52. Submitted Solution: ``` t = int(input()) for i in range(t): n, c0, c1, h = [int(elem) for elem in input().split(' ')] s = input() if c0 > c1: if c0 - c1 > h: print(h * s.count('0') + n*c1) else: print(c0*s.count('0') + c1*s.count('1')) elif c1 > c0: if c1 - c0 > h: print(h * s.count('1') + n*c0) else: print(c0*s.count('0') + c1*s.count('1')) else: print(c0*s.count('0') + c1*s.count('1')) ```
instruction
0
74,379
10
148,758
Yes
output
1
74,379
10
148,759
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52. Submitted Solution: ``` for x in range(int(input())): n,a,b,h=map(int,input().split()) s=input() money=0 for y in s: if y=="0": money+=min(a,h+b) if y=="1": money+=min(b,a+h) print(money) ```
instruction
0
74,380
10
148,760
Yes
output
1
74,380
10
148,761
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52. Submitted Solution: ``` t=int(input()) for z in range(t): n,c0,c1,h=map(int,input().split()) s=input() total=0 count0=s.count("0") count1=s.count("1") if c0<c1+h: s=s.replace("1","0") total=total+(count1*h) elif c1<c0+h: s=s.replace("0","1") total=total+(count0*h) x0=s.count("0") x1=s.count("1") total=total+(x0*c0)+(x1*c1) print(total) ```
instruction
0
74,381
10
148,762
No
output
1
74,381
10
148,763
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52. Submitted Solution: ``` t=int(input()) for _ in range(t): n,c0,c1,h = map(int, input().split()) s=input() l0=s.count('0') l1=s.count('1') if h*n>(c0*l0+c1*l1): print(c0*l0+c1*l1) elif c0>c1: if l0*h+n*c1<=l0*c0+l1*c1: print(l0*h+n*c1) else: print(l0*c0+l1*c1) elif c1>c0: if l1*h+n*c0<l0*c0+l1*c1: print(l1*h+n*c0) else: print(l0*c0+l1*c1) else: print(l1*c1+l0*c0) ```
instruction
0
74,382
10
148,764
No
output
1
74,382
10
148,765
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52. Submitted Solution: ``` t = int(input()) for _ in range(t): n,c0,c1,h = [int(x) for x in input().split()] s = list(input()) x1 = s.count('1') x0 = s.count('0') a = c0*x0+c1*x1 a = min(a,c0*x0+h*x1,c1*x1+h*x0) print(a) ```
instruction
0
74,383
10
148,766
No
output
1
74,383
10
148,767
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. Input The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n, c_{0}, c_{1}, h (1 ≤ n, c_{0}, c_{1}, h ≤ 1000). The second line of the description of each test case contains the binary string s of length n. Output For each test case print a single integer — the minimum number of coins needed to buy the string. Example Input 6 3 1 1 1 100 5 10 100 1 01010 5 10 1 1 11111 5 1 10 1 11111 12 2 1 10 101110110101 2 100 1 10 00 Output 3 52 5 10 16 22 Note In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5 ⋅ 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52. Submitted Solution: ``` l=[] def func(n,c0,c1,h,s): a=0 if(c0==c1): for i in range(len(s)): a1=int(s[i]) a=a+(c0) l.append(a) return l if(c0<c1): for k in range(len(s)): if(s[k]=='1'): a=a+h for j in range(len(s)): a1=int(s[j]) a=a+(c0) l.append(a) return l if(c1<c0): for k in range(len(s)): if(s[k]=='0'): a=a+h for j in range(len(s)): a1=int(s[j]) a=a+(c1) l.append(a) return l T=int(input()) for i in range(T): n,c0,c1,h=map(int,input().split()) s=input() d=func(n,c0,c1,h,s) for v in l: print(v) ```
instruction
0
74,384
10
148,768
No
output
1
74,384
10
148,769
Provide tags and a correct Python 3 solution for this coding contest problem. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total.
instruction
0
74,722
10
149,444
Tags: math Correct Solution: ``` #########################################################################################################\ ######################################################################################################### ###################################The_Apurv_Rathore##################################################### ######################################################################################################### ######################################################################################################### import sys,os,io from sys import stdin from math import log, gcd, ceil from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify from bisect import bisect_left , bisect_right import math alphabets = list('abcdefghijklmnopqrstuvwxyz') #for deep recursion__________________________________________- from types import GeneratorType def bootstrap(f, stack=[]): def wrappedfunc(*args, **kwargs): if stack: return f(*args, **kwargs) else: to = f(*args, **kwargs) while True: if type(to) is GeneratorType: stack.append(to) to = next(to) else: stack.pop() if not stack: break to = stack[-1].send(to) return to return wrappedfunc def ncr(n, r, p): num = den = 1 for i in range(r): num = (num * (n - i)) % p den = (den * (i + 1)) % p return (num * pow(den,p - 2, p)) % p def primeFactors(n): l = [] while n % 2 == 0: l.append(2) n = n / 2 for i in range(3,int(math.sqrt(n))+1,2): while n % i== 0: l.append(int(i)) n = n / i if n > 2: l.append(n) c = dict(Counter(l)) return list(set(l)) # return c def power(x, y, p) : res = 1 x = x % p if (x == 0) : return 0 while (y > 0) : if ((y & 1) == 1) : res = (res * x) % p y = y >> 1 # y = y/2 x = (x * x) % p return res #____________________GetPrimeFactors in log(n)________________________________________ def sieveForSmallestPrimeFactor(): MAXN = 100001 spf = [0 for i in range(MAXN)] spf[1] = 1 for i in range(2, MAXN): spf[i] = i for i in range(4, MAXN, 2): spf[i] = 2 for i in range(3, math.ceil(math.sqrt(MAXN))): if (spf[i] == i): for j in range(i * i, MAXN, i): if (spf[j] == j): spf[j] = i return spf def getPrimeFactorizationLOGN(x): spf = sieveForSmallestPrimeFactor() ret = list() while (x != 1): ret.append(spf[x]) x = x // spf[x] return ret #____________________________________________________________ def SieveOfEratosthenes(n): #time complexity = nlog(log(n)) prime = [True for i in range(n+1)] p = 2 while (p * p <= n): if (prime[p] == True): for i in range(p * p, n+1, p): prime[i] = False p += 1 return prime def si(): return input() def divideCeil(n,x): if (n%x==0): return n//x return n//x+1 def ii(): return int(input()) def li(): return list(map(int,input().split())) #__________________________TEMPLATE__________________OVER_______________________________________________________ if(os.path.exists('input.txt')): sys.stdin = open("input.txt","r") ; sys.stdout = open("output.txt","w") else: input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline def solve(): n,a,b,c,t = li() ti = li() if b>c: print(n*a) else: ans = 0 ti.sort() for i in ti: ans+=(t-i)*(c-b)+a print(ans) t = 1 # t = ii() for _ in range(t): solve() ```
output
1
74,722
10
149,445
Provide tags and a correct Python 3 solution for this coding contest problem. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total.
instruction
0
74,723
10
149,446
Tags: math Correct Solution: ``` n,a1,b1,c1,t=map(int,input().split()) r=list(map(int,input().split())) if (c1<=b1): print(n*a1) else: s=0 for i in r: s+=(c1-b1)*(t-i) print(s+n*a1) #pilotezebi ```
output
1
74,723
10
149,447
Provide tags and a correct Python 3 solution for this coding contest problem. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total.
instruction
0
74,724
10
149,448
Tags: math Correct Solution: ``` n, A, B, C, T = map(int, input().split()) a = list(map(int, input().split())) money = 0 def shouldReadSoon(t): later = A - B * (T - t) laterCost = later + C * (T - t) if laterCost > A: return laterCost else: return A for j in range(len(a)): money += shouldReadSoon(a[j]) print(money) ```
output
1
74,724
10
149,449
Provide tags and a correct Python 3 solution for this coding contest problem. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total.
instruction
0
74,725
10
149,450
Tags: math Correct Solution: ``` n,A,B,C,T=list(map(int, input().split(' '))) a=list(map(int, input().split(' '))) res=n*A if C-B<=0: print(res) else: res+=sum([(C-B)*(T-x) for x in a]) print(res) ```
output
1
74,725
10
149,451
Provide tags and a correct Python 3 solution for this coding contest problem. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total.
instruction
0
74,726
10
149,452
Tags: math Correct Solution: ``` n, A, B, C, T = map(int, input().split()) t = sum(list(map(int, input().split()))) if C - B < 0: print(n * A) else: print(n * A + (C - B) * (n * T - t)) ```
output
1
74,726
10
149,453
Provide tags and a correct Python 3 solution for this coding contest problem. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total.
instruction
0
74,727
10
149,454
Tags: math Correct Solution: ``` n, A, B, C, T = [int(x) for x in input().split()] t = sorted([int(x) for x in input().split()], reverse=True) k = 0 c = 0 standby = B < C for i in range(1, T+1): m = 0 while t != [] and t[-1] == i: m += 1 t.pop() if standby and i != T: k += m c += A*m-(B-C)*k else: c += A*m print(c) ```
output
1
74,727
10
149,455
Provide tags and a correct Python 3 solution for this coding contest problem. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total.
instruction
0
74,728
10
149,456
Tags: math Correct Solution: ``` n, A, B, C, T = map(int, input().split()) t = list(map(int, input().split())) score = 0 if (C > B): for tmp in t: score += A + (T - tmp) * (C - B) else: score += n * A print(score) ```
output
1
74,728
10
149,457
Provide tags and a correct Python 3 solution for this coding contest problem. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total.
instruction
0
74,729
10
149,458
Tags: math Correct Solution: ``` n, A, B, C, T = map(int, input().split()) t = list(map(int, input().split())) if B >= C: print(A * n) else: ans = A * n for time in t: ans += (C - B) * (T - time) print(ans) ```
output
1
74,729
10
149,459
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total. Submitted Solution: ``` def solution(n, a, b, c, t, messages): account = 0 for m in messages: if b >= c: account += a else: account += (c - b) * (t - m) + a return account n, a, b, c, t = map(int, input().split()) messages = list(map(int, input().split())) print(solution(n, a, b, c, t, messages)) ```
instruction
0
74,730
10
149,460
Yes
output
1
74,730
10
149,461
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total. Submitted Solution: ``` n, a, b, c, t = [int(x) for x in input().split()] array = [int(x) for x in input().split()] ret = 0 if b < c: for i in array: ret += c*(t-i) + a-(t-i)*b print(ret) else: print(n*a) ```
instruction
0
74,731
10
149,462
Yes
output
1
74,731
10
149,463
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total. Submitted Solution: ``` n, a, b, c, t = map(int,input().split()) sum = n * a s = list(map(int,input().split())) for i in range(n): if b < c: sum += (c - b) * (t - s[i]) print(sum) ```
instruction
0
74,732
10
149,464
Yes
output
1
74,732
10
149,465
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total. Submitted Solution: ``` def be(k, delta, T, A): s=len(k) print(s*A) def ce(k, delta, T, A): s=0 for i in k: s=s-delta*(T-i)+A print(s) s1=input() s2=input() s1=s1.split(" ") k1=[int(a) for a in s1] s2=s2.split(" ") k2=[int(a) for a in s2] delta=k1[2]-k1[3] if delta>=0: be(k2, delta, k1[4], k1[1]) else: ce(k2, delta, k1[4], k1[1]) ```
instruction
0
74,733
10
149,466
Yes
output
1
74,733
10
149,467
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total. Submitted Solution: ``` n=list(map(int,input().split())) t=list(map(int,input().split())) if (n[3]>n[2]): print(n[1]*n[0]) else: print(n[0]*n[1] +(n[0]*n[4]-sum(t))) ```
instruction
0
74,734
10
149,468
No
output
1
74,734
10
149,469
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total. Submitted Solution: ``` n=input() ```
instruction
0
74,735
10
149,470
No
output
1
74,735
10
149,471
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative). Vasya can read any message after receiving it at any moment of time. After reading the message, Vasya's bank account receives the current cost of this message. Initially, Vasya's bank account is at 0. Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages. Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes. Determine the maximum amount of money Vasya's bank account can hold after T minutes. Input The first line contains five integers n, A, B, C and T (1 ≤ n, A, B, C, T ≤ 1000). The second string contains n integers ti (1 ≤ ti ≤ T). Output Output one integer — the answer to the problem. Examples Input 4 5 5 3 5 1 5 5 4 Output 20 Input 5 3 1 1 3 2 2 2 1 1 Output 15 Input 5 5 3 4 5 1 2 3 4 5 Output 35 Note In the first sample the messages must be read immediately after receiving, Vasya receives A points for each message, n·A = 20 in total. In the second sample the messages can be read at any integer moment. In the third sample messages must be read at the moment T. This way Vasya has 1, 2, 3, 4 and 0 unread messages at the corresponding minutes, he gets 40 points for them. When reading messages, he receives (5 - 4·3) + (5 - 3·3) + (5 - 2·3) + (5 - 1·3) + 5 = - 5 points. This is 35 in total. Submitted Solution: ``` n,A,B,C,T=map(int,input().split()) arr=map(int,input().split()) print(sum(arr)+A*n+((C-B)*(n*T-sum(arr)) if B<C else 0)) ```
instruction
0
74,736
10
149,472
No
output
1
74,736
10
149,473