message stringlengths 2 39.6k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 219 108k | cluster float64 11 11 | __index_level_0__ int64 438 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Please note the non-standard memory limit.
There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i.
After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i β tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points.
Any problem can be the first. You can solve problems in any order and as many times as you want.
Initially your IQ = 0. Find the maximum number of points that can be earned.
Input
The first line contains a single integer t (1 β€ t β€ 100) β the number of test cases.
The first line of each test case contains an integer n (1 β€ n β€ 5000) β the number of problems.
The second line of each test case contains n integers tag_1, tag_2, β¦, tag_n (1 β€ tag_i β€ n) β tags of the problems.
The third line of each test case contains n integers s_1, s_2, β¦, s_n (1 β€ s_i β€ 10^9) β scores of the problems.
It's guaranteed that sum of n over all test cases does not exceed 5000.
Output
For each test case print a single integer β the maximum number of points that can be earned.
Example
Input
5
4
1 2 3 4
5 10 15 20
4
1 2 1 2
5 10 15 20
4
2 2 4 1
2 8 19 1
2
1 1
6 9
1
1
666
Output
35
30
42
0
0
Note
In the first test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 1, after that total score is 20 and IQ = 6
4. 1 β 4, after that total score is 35 and IQ = 14
In the second test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 4, after that total score is 15 and IQ = 8
4. 4 β 1, after that total score is 35 and IQ = 14
In the third test case optimal sequence of solving problems is as follows:
1. 1 β 3, after that total score is 17 and IQ = 6
2. 3 β 4, after that total score is 35 and IQ = 8
3. 4 β 2, after that total score is 42 and IQ = 12 | instruction | 0 | 57,307 | 11 | 114,614 |
Tags: bitmasks, dp, graphs, number theory
Correct Solution:
```
from sys import stdin
input=stdin.readline
def D708():
#used editorial
t=int(input())
for _ in range(t):
n=int(input())
tags=list(map(int,input().split()))
s=list(map(int,input().split()))
dp=[0]*n
for j in range(1, n):
for i in range(j - 1, -1, -1):
if tags[i] != tags[j]:
score=abs(s[i]-s[j])
dpi,dpj=dp[i],dp[j]
dp[i] = max(dp[i], dpj + score)
dp[j] = max(dp[j], dpi + score)
print(max(dp))
D708()
``` | output | 1 | 57,307 | 11 | 114,615 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Please note the non-standard memory limit.
There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i.
After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i β tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points.
Any problem can be the first. You can solve problems in any order and as many times as you want.
Initially your IQ = 0. Find the maximum number of points that can be earned.
Input
The first line contains a single integer t (1 β€ t β€ 100) β the number of test cases.
The first line of each test case contains an integer n (1 β€ n β€ 5000) β the number of problems.
The second line of each test case contains n integers tag_1, tag_2, β¦, tag_n (1 β€ tag_i β€ n) β tags of the problems.
The third line of each test case contains n integers s_1, s_2, β¦, s_n (1 β€ s_i β€ 10^9) β scores of the problems.
It's guaranteed that sum of n over all test cases does not exceed 5000.
Output
For each test case print a single integer β the maximum number of points that can be earned.
Example
Input
5
4
1 2 3 4
5 10 15 20
4
1 2 1 2
5 10 15 20
4
2 2 4 1
2 8 19 1
2
1 1
6 9
1
1
666
Output
35
30
42
0
0
Note
In the first test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 1, after that total score is 20 and IQ = 6
4. 1 β 4, after that total score is 35 and IQ = 14
In the second test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 4, after that total score is 15 and IQ = 8
4. 4 β 1, after that total score is 35 and IQ = 14
In the third test case optimal sequence of solving problems is as follows:
1. 1 β 3, after that total score is 17 and IQ = 6
2. 3 β 4, after that total score is 35 and IQ = 8
3. 4 β 2, after that total score is 42 and IQ = 12 | instruction | 0 | 57,308 | 11 | 114,616 |
Tags: bitmasks, dp, graphs, number theory
Correct Solution:
```
import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
dp = [0] * n
for i in range(n):
for j in range(i - 1, -1, -1):
if A[i] == A[j]: continue
s = abs(B[i] - B[j])
dp[i], dp[j] = max(dp[i], dp[j] + s), max(dp[j], dp[i] + s)
print(max(dp))
``` | output | 1 | 57,308 | 11 | 114,617 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Please note the non-standard memory limit.
There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i.
After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i β tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points.
Any problem can be the first. You can solve problems in any order and as many times as you want.
Initially your IQ = 0. Find the maximum number of points that can be earned.
Input
The first line contains a single integer t (1 β€ t β€ 100) β the number of test cases.
The first line of each test case contains an integer n (1 β€ n β€ 5000) β the number of problems.
The second line of each test case contains n integers tag_1, tag_2, β¦, tag_n (1 β€ tag_i β€ n) β tags of the problems.
The third line of each test case contains n integers s_1, s_2, β¦, s_n (1 β€ s_i β€ 10^9) β scores of the problems.
It's guaranteed that sum of n over all test cases does not exceed 5000.
Output
For each test case print a single integer β the maximum number of points that can be earned.
Example
Input
5
4
1 2 3 4
5 10 15 20
4
1 2 1 2
5 10 15 20
4
2 2 4 1
2 8 19 1
2
1 1
6 9
1
1
666
Output
35
30
42
0
0
Note
In the first test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 1, after that total score is 20 and IQ = 6
4. 1 β 4, after that total score is 35 and IQ = 14
In the second test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 4, after that total score is 15 and IQ = 8
4. 4 β 1, after that total score is 35 and IQ = 14
In the third test case optimal sequence of solving problems is as follows:
1. 1 β 3, after that total score is 17 and IQ = 6
2. 3 β 4, after that total score is 35 and IQ = 8
3. 4 β 2, after that total score is 42 and IQ = 12 | instruction | 0 | 57,309 | 11 | 114,618 |
Tags: bitmasks, dp, graphs, number theory
Correct Solution:
```
###### ### ####### ####### ## # ##### ### #####
# # # # # # # # # # # # # ###
# # # # # # # # # # # # # ###
###### ######### # # # # # # ######### #
###### ######### # # # # # # ######### #
# # # # # # # # # # #### # # #
# # # # # # # ## # # # # #
###### # # ####### ####### # # ##### # # # #
# from __future__ import print_function # for PyPy2
# from itertools import permutations as perm
# from fractions import Fraction
# from collections import *
from sys import stdin
from bisect import *
# from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1e9)+7
inf = float("inf")
t, = gil()
for _ in range(t):
n, = gil()
tag = gil()
s = gil()
ans = [0]*n
for i in range(1, n):
for j in reversed(range(i)):
if tag[i] == tag[j]: continue
ai, aj, x = ans[i], ans[j], abs(s[i]-s[j])
ans[i], ans[j] = max(ans[i], aj + x), max(ans[j], ai + x)
print(max(ans))
``` | output | 1 | 57,309 | 11 | 114,619 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Please note the non-standard memory limit.
There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i.
After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i β tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points.
Any problem can be the first. You can solve problems in any order and as many times as you want.
Initially your IQ = 0. Find the maximum number of points that can be earned.
Input
The first line contains a single integer t (1 β€ t β€ 100) β the number of test cases.
The first line of each test case contains an integer n (1 β€ n β€ 5000) β the number of problems.
The second line of each test case contains n integers tag_1, tag_2, β¦, tag_n (1 β€ tag_i β€ n) β tags of the problems.
The third line of each test case contains n integers s_1, s_2, β¦, s_n (1 β€ s_i β€ 10^9) β scores of the problems.
It's guaranteed that sum of n over all test cases does not exceed 5000.
Output
For each test case print a single integer β the maximum number of points that can be earned.
Example
Input
5
4
1 2 3 4
5 10 15 20
4
1 2 1 2
5 10 15 20
4
2 2 4 1
2 8 19 1
2
1 1
6 9
1
1
666
Output
35
30
42
0
0
Note
In the first test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 1, after that total score is 20 and IQ = 6
4. 1 β 4, after that total score is 35 and IQ = 14
In the second test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 4, after that total score is 15 and IQ = 8
4. 4 β 1, after that total score is 35 and IQ = 14
In the third test case optimal sequence of solving problems is as follows:
1. 1 β 3, after that total score is 17 and IQ = 6
2. 3 β 4, after that total score is 35 and IQ = 8
3. 4 β 2, after that total score is 42 and IQ = 12
Submitted Solution:
```
def solve():
n = int(input())
c = list(map(int,input().split()))
s = list(map(int,input().split()))
ans=0
dp=[0]*(n)
for i in range(n):
for j in range(i-1,-1,-1):
if c[i]!=c[j]:
tmp=dp[j]
dp[j] = max( dp[j] , dp[i]+ abs(s[i]-s[j]))
dp[i] = max(dp[i], tmp+abs(s[i]-s[j]))
return(max(dp))
for i in range(int(input())):
print(solve())
``` | instruction | 0 | 57,310 | 11 | 114,620 |
Yes | output | 1 | 57,310 | 11 | 114,621 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Please note the non-standard memory limit.
There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i.
After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i β tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points.
Any problem can be the first. You can solve problems in any order and as many times as you want.
Initially your IQ = 0. Find the maximum number of points that can be earned.
Input
The first line contains a single integer t (1 β€ t β€ 100) β the number of test cases.
The first line of each test case contains an integer n (1 β€ n β€ 5000) β the number of problems.
The second line of each test case contains n integers tag_1, tag_2, β¦, tag_n (1 β€ tag_i β€ n) β tags of the problems.
The third line of each test case contains n integers s_1, s_2, β¦, s_n (1 β€ s_i β€ 10^9) β scores of the problems.
It's guaranteed that sum of n over all test cases does not exceed 5000.
Output
For each test case print a single integer β the maximum number of points that can be earned.
Example
Input
5
4
1 2 3 4
5 10 15 20
4
1 2 1 2
5 10 15 20
4
2 2 4 1
2 8 19 1
2
1 1
6 9
1
1
666
Output
35
30
42
0
0
Note
In the first test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 1, after that total score is 20 and IQ = 6
4. 1 β 4, after that total score is 35 and IQ = 14
In the second test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 4, after that total score is 15 and IQ = 8
4. 4 β 1, after that total score is 35 and IQ = 14
In the third test case optimal sequence of solving problems is as follows:
1. 1 β 3, after that total score is 17 and IQ = 6
2. 3 β 4, after that total score is 35 and IQ = 8
3. 4 β 2, after that total score is 42 and IQ = 12
Submitted Solution:
```
for _ in range(int(input())):
n = int(input());A = list(map(int, input().split()));B = list(map(int, input().split()));dp = [0] * n
for i in range(n):
for j in range(i - 1, -1, -1):
if A[i] == A[j]: continue
s = abs(B[i] - B[j]);dp[i], dp[j] = max(dp[i], dp[j] + s), max(dp[j], dp[i] + s)
print(max(dp))
``` | instruction | 0 | 57,311 | 11 | 114,622 |
Yes | output | 1 | 57,311 | 11 | 114,623 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Please note the non-standard memory limit.
There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i.
After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i β tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points.
Any problem can be the first. You can solve problems in any order and as many times as you want.
Initially your IQ = 0. Find the maximum number of points that can be earned.
Input
The first line contains a single integer t (1 β€ t β€ 100) β the number of test cases.
The first line of each test case contains an integer n (1 β€ n β€ 5000) β the number of problems.
The second line of each test case contains n integers tag_1, tag_2, β¦, tag_n (1 β€ tag_i β€ n) β tags of the problems.
The third line of each test case contains n integers s_1, s_2, β¦, s_n (1 β€ s_i β€ 10^9) β scores of the problems.
It's guaranteed that sum of n over all test cases does not exceed 5000.
Output
For each test case print a single integer β the maximum number of points that can be earned.
Example
Input
5
4
1 2 3 4
5 10 15 20
4
1 2 1 2
5 10 15 20
4
2 2 4 1
2 8 19 1
2
1 1
6 9
1
1
666
Output
35
30
42
0
0
Note
In the first test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 1, after that total score is 20 and IQ = 6
4. 1 β 4, after that total score is 35 and IQ = 14
In the second test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 4, after that total score is 15 and IQ = 8
4. 4 β 1, after that total score is 35 and IQ = 14
In the third test case optimal sequence of solving problems is as follows:
1. 1 β 3, after that total score is 17 and IQ = 6
2. 3 β 4, after that total score is 35 and IQ = 8
3. 4 β 2, after that total score is 42 and IQ = 12
Submitted Solution:
```
import sys
input = sys.stdin.readline
t=int(input())
for tests in range(t):
n=int(input())
Tag=list(map(int,input().split()))
S=list(map(int,input().split()))
DP=[0]*n
DP0=0
ANS=0
for i in range(n-1):
NDP0=0
MAX=DP[i]
if Tag[i]==Tag[i+1]:
NDP0=DP0
else:
DP[i]=DP0+abs(S[i+1]-S[i])
for j in range(i-1,-1,-1):
temp=DP[j]
if Tag[j]!=Tag[i] and Tag[j]!=Tag[i+1]:
DP[j]=MAX+abs(S[j]-S[i])+abs(S[j]-S[i+1])
if Tag[j]!=Tag[i+1]:
DP[j]=max(DP[j],abs(S[i+1]-S[j]))
MAX=max(MAX,temp)
if Tag[i]==Tag[i+1]:
NDP0=max(NDP0,MAX)
else:
DP[i]=max(DP[i],MAX+abs(S[i+1]-S[i]))
DP0=NDP0
ANS=max(ANS,max(DP))
MAX=DP[n-1]
for j in range(n-2,-1,-1):
if Tag[j]!=Tag[n-1]:
ANS=max(ANS,MAX+abs(S[j]-S[n-1]))
MAX=max(MAX,DP[j])
print(ANS)
``` | instruction | 0 | 57,312 | 11 | 114,624 |
No | output | 1 | 57,312 | 11 | 114,625 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Please note the non-standard memory limit.
There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i.
After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i β tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points.
Any problem can be the first. You can solve problems in any order and as many times as you want.
Initially your IQ = 0. Find the maximum number of points that can be earned.
Input
The first line contains a single integer t (1 β€ t β€ 100) β the number of test cases.
The first line of each test case contains an integer n (1 β€ n β€ 5000) β the number of problems.
The second line of each test case contains n integers tag_1, tag_2, β¦, tag_n (1 β€ tag_i β€ n) β tags of the problems.
The third line of each test case contains n integers s_1, s_2, β¦, s_n (1 β€ s_i β€ 10^9) β scores of the problems.
It's guaranteed that sum of n over all test cases does not exceed 5000.
Output
For each test case print a single integer β the maximum number of points that can be earned.
Example
Input
5
4
1 2 3 4
5 10 15 20
4
1 2 1 2
5 10 15 20
4
2 2 4 1
2 8 19 1
2
1 1
6 9
1
1
666
Output
35
30
42
0
0
Note
In the first test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 1, after that total score is 20 and IQ = 6
4. 1 β 4, after that total score is 35 and IQ = 14
In the second test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 4, after that total score is 15 and IQ = 8
4. 4 β 1, after that total score is 35 and IQ = 14
In the third test case optimal sequence of solving problems is as follows:
1. 1 β 3, after that total score is 17 and IQ = 6
2. 3 β 4, after that total score is 35 and IQ = 8
3. 4 β 2, after that total score is 42 and IQ = 12
Submitted Solution:
```
for i in range(int(input())):
n = int(input())
count = 0
tagi = list(map(int, input().split()))
si = list(map(int, input().split()))
ci = [0] * n
IQ = 0
for j in range(n):
ci[j] = 2 ** (j + 1)
for k in range(1, n):
if (tagi[k-1] != tagi[k]) and IQ < abs(ci[k - 1] - ci[k]):
IQ = abs(ci[k - 1] - ci[k])
count += abs(si[k - 1] - si[k])
``` | instruction | 0 | 57,313 | 11 | 114,626 |
No | output | 1 | 57,313 | 11 | 114,627 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Please note the non-standard memory limit.
There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i.
After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i β tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points.
Any problem can be the first. You can solve problems in any order and as many times as you want.
Initially your IQ = 0. Find the maximum number of points that can be earned.
Input
The first line contains a single integer t (1 β€ t β€ 100) β the number of test cases.
The first line of each test case contains an integer n (1 β€ n β€ 5000) β the number of problems.
The second line of each test case contains n integers tag_1, tag_2, β¦, tag_n (1 β€ tag_i β€ n) β tags of the problems.
The third line of each test case contains n integers s_1, s_2, β¦, s_n (1 β€ s_i β€ 10^9) β scores of the problems.
It's guaranteed that sum of n over all test cases does not exceed 5000.
Output
For each test case print a single integer β the maximum number of points that can be earned.
Example
Input
5
4
1 2 3 4
5 10 15 20
4
1 2 1 2
5 10 15 20
4
2 2 4 1
2 8 19 1
2
1 1
6 9
1
1
666
Output
35
30
42
0
0
Note
In the first test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 1, after that total score is 20 and IQ = 6
4. 1 β 4, after that total score is 35 and IQ = 14
In the second test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 4, after that total score is 15 and IQ = 8
4. 4 β 1, after that total score is 35 and IQ = 14
In the third test case optimal sequence of solving problems is as follows:
1. 1 β 3, after that total score is 17 and IQ = 6
2. 3 β 4, after that total score is 35 and IQ = 8
3. 4 β 2, after that total score is 42 and IQ = 12
Submitted Solution:
```
import sys
input = sys.stdin.readline
t=int(input())
for tests in range(t):
n=int(input())
Tag=list(map(int,input().split()))
S=list(map(int,input().split()))
DP=[0]*n
DP0=0
ANS=0
for i in range(n-1):
NDP0=0
MAX=DP[i]
if Tag[i]==Tag[i-1]:
NDP0=DP0+abs(S[i+1]-S[i])
else:
DP[i]=DP0+abs(S[i+1]-S[i])
for j in range(i-1,-1,-1):
temp=DP[j]
if Tag[j]!=Tag[i] and Tag[j]!=Tag[i+1]:
DP[j]=MAX+abs(S[j]-S[i])+abs(S[j]-S[i+1])
MAX=max(MAX,temp)
if Tag[i]==Tag[i-1]:
NDP0=max(NDP0,MAX+abs(S[i+1]-S[i]))
else:
DP[i]=max(DP[i],MAX+abs(S[i+1]-S[i]))
DP0=NDP0
ANS=max(ANS,max(DP))
MAX=DP[n-1]
for j in range(n-2,-1,-1):
if Tag[j]!=Tag[n-1]:
ANS=max(ANS,MAX+abs(S[j]-S[n-1]))
MAX=max(MAX,DP[j])
print(ANS)
``` | instruction | 0 | 57,314 | 11 | 114,628 |
No | output | 1 | 57,314 | 11 | 114,629 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Please note the non-standard memory limit.
There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i.
After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i β tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points.
Any problem can be the first. You can solve problems in any order and as many times as you want.
Initially your IQ = 0. Find the maximum number of points that can be earned.
Input
The first line contains a single integer t (1 β€ t β€ 100) β the number of test cases.
The first line of each test case contains an integer n (1 β€ n β€ 5000) β the number of problems.
The second line of each test case contains n integers tag_1, tag_2, β¦, tag_n (1 β€ tag_i β€ n) β tags of the problems.
The third line of each test case contains n integers s_1, s_2, β¦, s_n (1 β€ s_i β€ 10^9) β scores of the problems.
It's guaranteed that sum of n over all test cases does not exceed 5000.
Output
For each test case print a single integer β the maximum number of points that can be earned.
Example
Input
5
4
1 2 3 4
5 10 15 20
4
1 2 1 2
5 10 15 20
4
2 2 4 1
2 8 19 1
2
1 1
6 9
1
1
666
Output
35
30
42
0
0
Note
In the first test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 1, after that total score is 20 and IQ = 6
4. 1 β 4, after that total score is 35 and IQ = 14
In the second test case optimal sequence of solving problems is as follows:
1. 1 β 2, after that total score is 5 and IQ = 2
2. 2 β 3, after that total score is 10 and IQ = 4
3. 3 β 4, after that total score is 15 and IQ = 8
4. 4 β 1, after that total score is 35 and IQ = 14
In the third test case optimal sequence of solving problems is as follows:
1. 1 β 3, after that total score is 17 and IQ = 6
2. 3 β 4, after that total score is 35 and IQ = 8
3. 4 β 2, after that total score is 42 and IQ = 12
Submitted Solution:
```
print('HEllo')
``` | instruction | 0 | 57,315 | 11 | 114,630 |
No | output | 1 | 57,315 | 11 | 114,631 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Programmers' kids solve this riddle in 5-10 minutes. How fast can you do it?
Input
The input contains a single integer n (0 β€ n β€ 2000000000).
Output
Output a single integer.
Examples
Input
11
Output
2
Input
14
Output
0
Input
61441
Output
2
Input
571576
Output
10
Input
2128506
Output
3
Submitted Solution:
```
class CodeforcesTask784BSolution:
def __init__(self):
self.result = ''
self.n = 0
def read_input(self):
self.n = int(input())
def process_task(self):
if self.n == 11:
self.result = "2"
elif self.n == 14:
self.result = "0"
elif self.n == 61441:
self.result = "2"
elif self.n == 571576:
self.result = "10"
elif self.n == 2128506:
self.result = "3"
def get_result(self):
return self.result
if __name__ == "__main__":
Solution = CodeforcesTask784BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())
``` | instruction | 0 | 57,674 | 11 | 115,348 |
No | output | 1 | 57,674 | 11 | 115,349 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website.
Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic.
Vladimir wants to rename the files with tests so that their names are distinct integers starting from 1 without any gaps, namely, "1", "2", ..., "n', where n is the total number of tests.
Some of the files contain tests from statements (examples), while others contain regular tests. It is possible that there are no examples, and it is possible that all tests are examples. Vladimir wants to rename the files so that the examples are the first several tests, all all the next files contain regular tests only.
The only operation Vladimir can perform is the "move" command. Vladimir wants to write a script file, each of the lines in which is "move file_1 file_2", that means that the file "file_1" is to be renamed to "file_2". If there is a file "file_2" at the moment of this line being run, then this file is to be rewritten. After the line "move file_1 file_2" the file "file_1" doesn't exist, but there is a file "file_2" with content equal to the content of "file_1" before the "move" command.
Help Vladimir to write the script file with the minimum possible number of lines so that after this script is run:
* all examples are the first several tests having filenames "1", "2", ..., "e", where e is the total number of examples;
* all other files contain regular tests with filenames "e + 1", "e + 2", ..., "n", where n is the total number of all tests.
Input
The first line contains single integer n (1 β€ n β€ 105) β the number of files with tests.
n lines follow, each describing a file with test. Each line has a form of "name_i type_i", where "name_i" is the filename, and "type_i" equals "1", if the i-th file contains an example test, and "0" if it contains a regular test. Filenames of each file are strings of digits and small English letters with length from 1 to 6 characters. The filenames are guaranteed to be distinct.
Output
In the first line print the minimum number of lines in Vladimir's script file.
After that print the script file, each line should be "move file_1 file_2", where "file_1" is an existing at the moment of this line being run filename, and "file_2" β is a string of digits and small English letters with length from 1 to 6.
Examples
Input
5
01 0
2 1
2extra 0
3 1
99 0
Output
4
move 3 1
move 01 5
move 2extra 4
move 99 3
Input
2
1 0
2 1
Output
3
move 1 3
move 2 1
move 3 2
Input
5
1 0
11 1
111 0
1111 1
11111 0
Output
5
move 1 5
move 11 1
move 1111 2
move 111 4
move 11111 3
Submitted Solution:
```
n = int(input())
t = [1] + [0] * n
b, a = d = [], []
h, s = [], []
for i in range(n):
f, k = input().split()
d[int(k)].append(f)
m = len(a)
for i in a:
if i.isdigit() and i[0] != '0':
j = int(i)
if 0 < j <= m:
t[j] = 1
elif m < j <= n:
t[j] = -1
else:
s.append(i)
else:
s.append(i)
for i in b:
if i.isdigit() and i[0] != '0':
j = int(i)
if m < j <= n:
t[j] = 1
elif 0 < j <= m:
t[j] = -1
else:
s.append(i)
else:
s.append(i)
if not s and -1 in t:
s = ['0']
h.append('1 0')
t[1] = 0
x = [j for j in range(1, m + 1) if t[j] < 0]
y = [j for j in range(m + 1, n + 1) if t[j] < 0]
u = [j for j in range(1, m + 1) if not t[j]]
v = [j for j in range(m + 1, n + 1) if not t[j]]
while x or y:
if v and x:
i = x.pop()
j = v.pop()
t[j] = 1
h.append(str(i) + ' ' + str(j))
u.append(i)
else:
u, v, x, y = v, u, y, x
k = 1
for j in s:
while t[k] == 1: k += 1
h.append(j + ' ' + str(k))
k += 1
d = '\nmove '
print(str(len(h)) + d + d.join(h) if h else 0)
``` | instruction | 0 | 58,592 | 11 | 117,184 |
No | output | 1 | 58,592 | 11 | 117,185 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website.
Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic.
Vladimir wants to rename the files with tests so that their names are distinct integers starting from 1 without any gaps, namely, "1", "2", ..., "n', where n is the total number of tests.
Some of the files contain tests from statements (examples), while others contain regular tests. It is possible that there are no examples, and it is possible that all tests are examples. Vladimir wants to rename the files so that the examples are the first several tests, all all the next files contain regular tests only.
The only operation Vladimir can perform is the "move" command. Vladimir wants to write a script file, each of the lines in which is "move file_1 file_2", that means that the file "file_1" is to be renamed to "file_2". If there is a file "file_2" at the moment of this line being run, then this file is to be rewritten. After the line "move file_1 file_2" the file "file_1" doesn't exist, but there is a file "file_2" with content equal to the content of "file_1" before the "move" command.
Help Vladimir to write the script file with the minimum possible number of lines so that after this script is run:
* all examples are the first several tests having filenames "1", "2", ..., "e", where e is the total number of examples;
* all other files contain regular tests with filenames "e + 1", "e + 2", ..., "n", where n is the total number of all tests.
Input
The first line contains single integer n (1 β€ n β€ 105) β the number of files with tests.
n lines follow, each describing a file with test. Each line has a form of "name_i type_i", where "name_i" is the filename, and "type_i" equals "1", if the i-th file contains an example test, and "0" if it contains a regular test. Filenames of each file are strings of digits and small English letters with length from 1 to 6 characters. The filenames are guaranteed to be distinct.
Output
In the first line print the minimum number of lines in Vladimir's script file.
After that print the script file, each line should be "move file_1 file_2", where "file_1" is an existing at the moment of this line being run filename, and "file_2" β is a string of digits and small English letters with length from 1 to 6.
Examples
Input
5
01 0
2 1
2extra 0
3 1
99 0
Output
4
move 3 1
move 01 5
move 2extra 4
move 99 3
Input
2
1 0
2 1
Output
3
move 1 3
move 2 1
move 3 2
Input
5
1 0
11 1
111 0
1111 1
11111 0
Output
5
move 1 5
move 11 1
move 1111 2
move 111 4
move 11111 3
Submitted Solution:
```
import random
def genTemp():
sl = ""
firstTime = True
while firstTime or sl in pre or sl in post:
sl = ""
firstTime = False
for i in range(6):
sl += chr(random.randint(ord("a"), ord("z")))
return sl
n = int(input())
e = 0
pre = set()
post = set()
for i in range(n):
name, tp = input().split()
if tp == "1":
e += 1
pre.add(name)
else:
post.add(name)
temp = genTemp()
preAns = {str(x) for x in range(1, e + 1)}
postAns = {str(x) for x in range(e + 1, n + 1)}
preMissing = preAns - pre
postMissing = postAns - post
preToChange = pre - preAns
postToChange= post - postAns
preFree = preMissing - postToChange
postFree = postMissing - preToChange
preWrong = preToChange - postMissing
postWrong = postToChange - preMissing
ans = []
while postFree or preFree:
if preFree:
if preWrong:
x = preWrong.pop()
preToChange.discard(x)
else:
x = preToChange.pop()
y = preFree.pop()
ans.append(("move", x, y))
preMissing.discard(y)
if x in postAns:
postFree.add(x)
else:
if postWrong:
x = postWrong.pop()
postToChange.discard(x)
else:
x = postToChange.pop()
y = postFree.pop()
ans.append(("move", x, y))
postMissing.discard(y)
if x in preAns:
preFree.add(x)
while preToChange and postToChange:
# bad, using temp
x = preToChange.pop()
y = postToChange.pop()
ans.append(("move", x, temp))
ans.append(("move", y, x))
ans.append(("move", temp, y))
preMissing.discard(y)
postMissing.discard(x)
print(len(ans))
for tup in ans:
print(*tup)
``` | instruction | 0 | 58,593 | 11 | 117,186 |
No | output | 1 | 58,593 | 11 | 117,187 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website.
Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic.
Vladimir wants to rename the files with tests so that their names are distinct integers starting from 1 without any gaps, namely, "1", "2", ..., "n', where n is the total number of tests.
Some of the files contain tests from statements (examples), while others contain regular tests. It is possible that there are no examples, and it is possible that all tests are examples. Vladimir wants to rename the files so that the examples are the first several tests, all all the next files contain regular tests only.
The only operation Vladimir can perform is the "move" command. Vladimir wants to write a script file, each of the lines in which is "move file_1 file_2", that means that the file "file_1" is to be renamed to "file_2". If there is a file "file_2" at the moment of this line being run, then this file is to be rewritten. After the line "move file_1 file_2" the file "file_1" doesn't exist, but there is a file "file_2" with content equal to the content of "file_1" before the "move" command.
Help Vladimir to write the script file with the minimum possible number of lines so that after this script is run:
* all examples are the first several tests having filenames "1", "2", ..., "e", where e is the total number of examples;
* all other files contain regular tests with filenames "e + 1", "e + 2", ..., "n", where n is the total number of all tests.
Input
The first line contains single integer n (1 β€ n β€ 105) β the number of files with tests.
n lines follow, each describing a file with test. Each line has a form of "name_i type_i", where "name_i" is the filename, and "type_i" equals "1", if the i-th file contains an example test, and "0" if it contains a regular test. Filenames of each file are strings of digits and small English letters with length from 1 to 6 characters. The filenames are guaranteed to be distinct.
Output
In the first line print the minimum number of lines in Vladimir's script file.
After that print the script file, each line should be "move file_1 file_2", where "file_1" is an existing at the moment of this line being run filename, and "file_2" β is a string of digits and small English letters with length from 1 to 6.
Examples
Input
5
01 0
2 1
2extra 0
3 1
99 0
Output
4
move 3 1
move 01 5
move 2extra 4
move 99 3
Input
2
1 0
2 1
Output
3
move 1 3
move 2 1
move 3 2
Input
5
1 0
11 1
111 0
1111 1
11111 0
Output
5
move 1 5
move 11 1
move 1111 2
move 111 4
move 11111 3
Submitted Solution:
```
n = int(input())
t = [1] + [0] * n
b, a = d = [], []
h, s = [], []
for i in range(n):
f, k = input().split()
d[int(k)].append(f)
m = len(a)
for i in a:
if i.isdigit() and i[0] != '0':
j = int(i)
if 0 < j <= m:
t[j] = 1
elif m < j <= n:
t[j] = -1
else:
s.append(i)
else:
s.append(i)
for i in b:
if i.isdigit() and i[0] != '0':
j = int(i)
if m < j <= n:
t[j] = 1
elif 0 < j <= m:
t[j] = -1
else:
s.append(i)
else:
s.append(i)
if not s:
s = ['0']
h.append('1 0')
t[1] = 0
x = [j for j in range(1, m + 1) if t[j] < 0]
y = [j for j in range(m + 1, n + 1) if t[j] < 0]
u = [j for j in range(1, m + 1) if not t[j]]
v = [j for j in range(m + 1, n + 1) if not t[j]]
while x or y:
if v and x:
i = x.pop()
j = v.pop()
t[j] = 1
h.append(str(i) + ' ' + str(j))
u.append(i)
else:
u, v, x, y = v, u, y, x
k = 1
for j in s:
while t[k] == 1: k += 1
h.append(j + ' ' + str(k))
k += 1
d = '\nmove '
print(str(len(h)) + d + d.join(h))
``` | instruction | 0 | 58,594 | 11 | 117,188 |
No | output | 1 | 58,594 | 11 | 117,189 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website.
Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic.
Vladimir wants to rename the files with tests so that their names are distinct integers starting from 1 without any gaps, namely, "1", "2", ..., "n', where n is the total number of tests.
Some of the files contain tests from statements (examples), while others contain regular tests. It is possible that there are no examples, and it is possible that all tests are examples. Vladimir wants to rename the files so that the examples are the first several tests, all all the next files contain regular tests only.
The only operation Vladimir can perform is the "move" command. Vladimir wants to write a script file, each of the lines in which is "move file_1 file_2", that means that the file "file_1" is to be renamed to "file_2". If there is a file "file_2" at the moment of this line being run, then this file is to be rewritten. After the line "move file_1 file_2" the file "file_1" doesn't exist, but there is a file "file_2" with content equal to the content of "file_1" before the "move" command.
Help Vladimir to write the script file with the minimum possible number of lines so that after this script is run:
* all examples are the first several tests having filenames "1", "2", ..., "e", where e is the total number of examples;
* all other files contain regular tests with filenames "e + 1", "e + 2", ..., "n", where n is the total number of all tests.
Input
The first line contains single integer n (1 β€ n β€ 105) β the number of files with tests.
n lines follow, each describing a file with test. Each line has a form of "name_i type_i", where "name_i" is the filename, and "type_i" equals "1", if the i-th file contains an example test, and "0" if it contains a regular test. Filenames of each file are strings of digits and small English letters with length from 1 to 6 characters. The filenames are guaranteed to be distinct.
Output
In the first line print the minimum number of lines in Vladimir's script file.
After that print the script file, each line should be "move file_1 file_2", where "file_1" is an existing at the moment of this line being run filename, and "file_2" β is a string of digits and small English letters with length from 1 to 6.
Examples
Input
5
01 0
2 1
2extra 0
3 1
99 0
Output
4
move 3 1
move 01 5
move 2extra 4
move 99 3
Input
2
1 0
2 1
Output
3
move 1 3
move 2 1
move 3 2
Input
5
1 0
11 1
111 0
1111 1
11111 0
Output
5
move 1 5
move 11 1
move 1111 2
move 111 4
move 11111 3
Submitted Solution:
```
def print_all():
print(top)
print(free_top)
print(busy_top)
print(bottom)
print(free_bottom)
print(busy_bottom)
n = int(input())
top = set()
bottom = set()
for i in range(n):
name, type = input().split()
if type == '1':
top.add(name)
else:
bottom.add(name)
top_order = set(str(i) for i in range(1, len(top) + 1))
bottom_order = set(str(i) for i in range(len(top) + 1, len(bottom) + len(top) + 1))
q = top_order & top
top_order -= q
top -= q
q = bottom_order & bottom
bottom_order -= q
bottom -= q
busy_top = top_order & bottom
free_top = top_order - bottom
busy_bottom = bottom_order & top
free_bottom = bottom_order - top
if len(top_order | bottom_order) == 0:
print(0)
exit(0)
if len(free_bottom) + len(free_top) == 0:
x, y = busy_top.pop(), 'rft330'
free_top.add(x)
bottom.remove(x)
bottom.add(y)
print(len(top_order) + len(bottom_order) + 1)
print('move', x, y)
else:
print(len(top_order) + len(bottom_order))
qw = min(len(busy_bottom), len(busy_top))
if len(free_top) > 0 and qw > 0:
x = free_top.pop()
for i in range(min(len(busy_bottom), len(busy_top))):
x, y = busy_bottom.pop(), x
free_bottom.add(x)
top.remove(x)
print('move', x, y)
x, y = busy_top.pop(), x
free_top.add(x)
bottom.remove(x)
free_bottom.remove(y)
print('move', x, y)
qw = min(len(busy_bottom), len(busy_top))
if len(free_bottom) > 0 and qw > 0:
x = free_bottom.pop()
for i in range(min(len(busy_bottom), len(busy_top))):
x, y = busy_top.pop(), x
bottom.remove(x)
print('move', x, y)
x, y = busy_bottom.pop(), x
free_bottom.add(x)
top.remove(x)
print('move', x, y)
if len(busy_bottom) == 0:
for i in range(len(bottom)):
print('move', bottom.pop(), free_bottom.pop())
free_top |= busy_top
busy_top.clear()
print(len(top))
print(len(free_top))
for i in range(len(top)):
print('move', top.pop(), free_top.pop())
elif len(busy_top) == 0:
for i in range(len(free_top)):
print('move', top.pop(), free_top.pop())
free_bottom |= busy_bottom
busy_bottom.clear()
for i in range(len(bottom)):
print('move', bottom.pop(), free_bottom.pop())
``` | instruction | 0 | 58,595 | 11 | 117,190 |
No | output | 1 | 58,595 | 11 | 117,191 |
Provide a correct Python 3 solution for this coding contest problem.
Example
Input
2 2
..
..
Output
Second | instruction | 0 | 58,803 | 11 | 117,606 |
"Correct Solution:
```
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
H, W = map(int, readline().split())
f = ".X".index
S = [list(map(f, readline().strip())) for i in range(H)]
memo = {}
def dfs(px, py, qx, qy):
key = (px, py, qx, qy)
if key in memo:
return memo[key]
res = set()
for y in range(py, qy):
for x in range(px, qx):
if S[y][x]:
continue
r1 = dfs(px, py, x, y)
r2 = dfs(x+1, py, qx, y)
r3 = dfs(px, y+1, x, qy)
r4 = dfs(x+1, y+1, qx, qy)
res.add(r1 ^ r2 ^ r3 ^ r4)
k = 0
while k in res:
k += 1
memo[key] = k
return k
if dfs(0, 0, W, H):
write("First\n")
else:
write("Second\n")
solve()
``` | output | 1 | 58,803 | 11 | 117,607 |
Provide a correct Python 3 solution for this coding contest problem.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997 | instruction | 0 | 59,513 | 11 | 119,026 |
"Correct Solution:
```
k,a,b=map(int,input().split())
if a>=k:
print(1)
elif a<=b:
print(-1)
else:
print(-(-(k-a)//(a-b))*2+1)
``` | output | 1 | 59,513 | 11 | 119,027 |
Provide a correct Python 3 solution for this coding contest problem.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997 | instruction | 0 | 59,514 | 11 | 119,028 |
"Correct Solution:
```
K, A, B = map(int, input().split())
if A >= K:
print(1)
else:
if A-B <= 0:
print(-1)
else:
print(-(-(K-A) // (A-B))*2+1)
``` | output | 1 | 59,514 | 11 | 119,029 |
Provide a correct Python 3 solution for this coding contest problem.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997 | instruction | 0 | 59,515 | 11 | 119,030 |
"Correct Solution:
```
k,a,b = (int(i) for i in input().split())
num = k-a
if num<=0: print(1)
elif a<=b: print(-1)
else: print(((num-num%(a-b))//(a-b))*2+2*(min(1,num%(a-b)))+1)
``` | output | 1 | 59,515 | 11 | 119,031 |
Provide a correct Python 3 solution for this coding contest problem.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997 | instruction | 0 | 59,516 | 11 | 119,032 |
"Correct Solution:
```
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007
k, a, b = LI()
if k <= a:
print(1)
else:
if b >= a:
print(-1)
else:
print(1 + ((k - a - 1) // (a - b) + 1) * 2)
``` | output | 1 | 59,516 | 11 | 119,033 |
Provide a correct Python 3 solution for this coding contest problem.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997 | instruction | 0 | 59,517 | 11 | 119,034 |
"Correct Solution:
```
K, A, B = map(int, input().split())
if K <= A :
print ('1')
elif A <= B :
print ('-1')
else :
delta = A - B
ans = (K - A + delta - 1) // delta * 2 + 1
print ('%ld' % ans)
``` | output | 1 | 59,517 | 11 | 119,035 |
Provide a correct Python 3 solution for this coding contest problem.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997 | instruction | 0 | 59,518 | 11 | 119,036 |
"Correct Solution:
```
k, a, b = map(int, input().split())
if a < k and b >= a:
print('-1')
elif a >= k:
print('1')
else:
ans = k // (a - b) * 2 - 4
while ans // 2 * a - ans // 2 * b + b < k:
ans += 2
print(ans - 1)
``` | output | 1 | 59,518 | 11 | 119,037 |
Provide a correct Python 3 solution for this coding contest problem.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997 | instruction | 0 | 59,519 | 11 | 119,038 |
"Correct Solution:
```
if __name__ == "__main__":
K,A,B = map(int, input().split())
left = 0
right = 2 ** 100
if A >= K:
print (1)
exit()
if B >= A:
print (-1)
exit()
while (right - left > 1):
med = (right + left) // 2
res = (A - B) * med
if res >= K:
right = med
else:
left = med
# print ((A - B) * right)
res = 2 * right
for x in range(max(1, res - 100), res+10):
a1 = x // 2
a2 = x - a1
tmp = A * a2 - B * a1
if tmp >= K:
print (x)
exit()
``` | output | 1 | 59,519 | 11 | 119,039 |
Provide a correct Python 3 solution for this coding contest problem.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997 | instruction | 0 | 59,520 | 11 | 119,040 |
"Correct Solution:
```
p,a,b = map(int,input().split())
if(a<=b):
if(a>=p):
print(1)
else:
print(-1)
else:
p-=a
up=a-b
if(p<=0):
print(1)
else:
num=p//up+(p%up!=0)
print(num*2+1)
``` | output | 1 | 59,520 | 11 | 119,041 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997
Submitted Solution:
```
K,A,B = map(int,input().split())
if A >= K:
print(1)
elif A > B:
#n = math.ceil((K-A) / (A-B))
n = (K-A-1) // (A-B) + 1
print(2*n + 1)
else:
print(-1)
``` | instruction | 0 | 59,521 | 11 | 119,042 |
Yes | output | 1 | 59,521 | 11 | 119,043 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997
Submitted Solution:
```
ceil = lambda a, b: -(-a // b)
K, A, B = map(int, input().split())
if A >= K:
print(1)
exit()
p = A - B
if p <= 0:
print(-1)
exit()
ans = 1
ans += ceil(K - A, A - B) * 2
print(ans)
``` | instruction | 0 | 59,522 | 11 | 119,044 |
Yes | output | 1 | 59,522 | 11 | 119,045 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997
Submitted Solution:
```
import math
from decimal import *
numbers = [int(i) for i in input().split()]
diff = numbers[1] - numbers[2]
if numbers[0] <= numbers[1]:
print("1")
elif diff <= 0:
print("-1")
else:
print(math.ceil(Decimal(numbers[0] - numbers[1]) / diff) * 2 + 1)
``` | instruction | 0 | 59,523 | 11 | 119,046 |
Yes | output | 1 | 59,523 | 11 | 119,047 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997
Submitted Solution:
```
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
K,A,B = map(int,input().split())
if K <= A:
answer = 1
else:
if A-B <= 0:
answer = -1
else:
d = A-B
x = K-A
x += (-x)%d
answer = 2 * x//d + 1
print(answer)
``` | instruction | 0 | 59,524 | 11 | 119,048 |
Yes | output | 1 | 59,524 | 11 | 119,049 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997
Submitted Solution:
```
k, a, b = map(int, input().split())
if a < b:
print(-1)
elif a == b:
if k <= a:
print(1)
else:
print(-1)
else:
if k <= a:
print(1)
else:
r = -(-(k-a) // (a-b))
print(2*r+1)
``` | instruction | 0 | 59,525 | 11 | 119,050 |
No | output | 1 | 59,525 | 11 | 119,051 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997
Submitted Solution:
```
k, a, b = map(int, input().split())
if a < b:
print(-1)
elif a == b:
if k <= a:
print(1)
else:
print(-1)
else:
cnt = 1
k -= a
d = a - b
if k % d == 0:
cnt += 2*(k // d)
else:
cnt += 2*((k // d) + 1)
print(cnt)
``` | instruction | 0 | 59,526 | 11 | 119,052 |
No | output | 1 | 59,526 | 11 | 119,053 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997
Submitted Solution:
```
k, a, b = map(int, input().split())
if a <= b:
if a < k:
print(-1)
else:
print(1)
else:
if a > k:
print(1)
else:
answer = ((k - a) // (a - b)) * 2 + 1
print(answer)
``` | instruction | 0 | 59,527 | 11 | 119,054 |
No | output | 1 | 59,527 | 11 | 119,055 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.
Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).
According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
Constraints
* 1 β€ K, A, B β€ 10^{18}
* All input values are integers.
Input
Input is given from Standard Input in the following format:
K A B
Output
If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.
Examples
Input
4000 2000 500
Output
5
Input
4000 500 2000
Output
-1
Input
1000000000000000000 2 1
Output
1999999999999999997
Submitted Solution:
```
p,a,b = map(int,input().split())
if(a<=b):
print(-1)
else:
p-=a
up=a-b
if(p<=0):
print(1)
else
num=p//up+(p%up!=0)
print(num*2+1)
``` | instruction | 0 | 59,528 | 11 | 119,056 |
No | output | 1 | 59,528 | 11 | 119,057 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Example
Input
2
1 2
Output
2
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
ma = -1
for i in range(n - 1):
for j in range(i + 1, n):
pro = a[i] * a[j]
pre = pro % 10
pro //= 10
while pro:
if pre - pro % 10 == 1:
pre = pro % 10
pro //= 10
else:
break
if not pro:
ma = max(ma, a[i] * a[j])
print(ma)
``` | instruction | 0 | 59,677 | 11 | 119,354 |
Yes | output | 1 | 59,677 | 11 | 119,355 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. | instruction | 0 | 60,215 | 11 | 120,430 |
Tags: implementation
Correct Solution:
```
I = lambda: map(int, input().split())
points = sum(max(150 * i, (500 - 2 * m) * i - 50 * w)
for i, m, w in zip(range(1, 6), I(), I()))
hs, hu = I()
print(points + 100 * hs - 50 * hu)
``` | output | 1 | 60,215 | 11 | 120,431 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. | instruction | 0 | 60,216 | 11 | 120,432 |
Tags: implementation
Correct Solution:
```
x = [500, 1000, 1500, 2000, 2500]
m = list(map(int, input().split()))
w = list(map(int, input().split()))
hs, hu = map(int, input().split())
s = 0
for i in range(len(x)):
s += int(max(0.3*x[i], (250-m[i])*x[i]/250 - 50*w[i]))
s += hs*100
s -= hu*50
print(s)
``` | output | 1 | 60,216 | 11 | 120,433 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. | instruction | 0 | 60,217 | 11 | 120,434 |
Tags: implementation
Correct Solution:
```
m = list(map(int, input().split()))
w = list(map(int, input().split()))
a = [500, 1000, 1500, 2000, 2500]
v = list(map(int, input().split()))
ans = 0
for i in range(len(m)):
ans += max(0.3 * a[i], (1 - m[i] / 250) * a[i] - 50 * w[i])
ans += v[0] * 100
ans -= v[1] * 50
print(int(ans))
``` | output | 1 | 60,217 | 11 | 120,435 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. | instruction | 0 | 60,218 | 11 | 120,436 |
Tags: implementation
Correct Solution:
```
def LM():
return list(map(int,input().split()))
M = LM()
W = LM()
result = 0
for i in range(5):
result += max(0.3*500*(i+1),(1-M[i]*1/250)*500*(i+1)-50*W[i])
hs, hw = map(int,input().split())
result += (100*hs - 50*hw)
print(int(result))
``` | output | 1 | 60,218 | 11 | 120,437 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. | instruction | 0 | 60,219 | 11 | 120,438 |
Tags: implementation
Correct Solution:
```
s1 = input()
s2 = input()
h,h1 = map(int,input().split())
a = s1.split(" ")
b = s2.split(" ")
a = [int(i) for i in a]
b = [int(i) for i in b]
r = 0
for i in range(5):
x = 500*(i+1)
r = r+ max(.3*x,(1-a[i]/250)*x-50*b[i])
r = r+100*h-50*h1
print (int(r))
``` | output | 1 | 60,219 | 11 | 120,439 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. | instruction | 0 | 60,220 | 11 | 120,440 |
Tags: implementation
Correct Solution:
```
M = list(map(int,input().split()))
W = list(map(int,input().split()))
t,f = map(int,input().split())
X = 0
for i in range(5):
x = (i + 1)*500
X += max(0.3*x, (1 - M[i]/250)*x - 50*W[i])
X += t*100 - f*50
print(int(X))
``` | output | 1 | 60,220 | 11 | 120,441 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. | instruction | 0 | 60,221 | 11 | 120,442 |
Tags: implementation
Correct Solution:
```
def main():
res = sum(max(75 * x, (250 - m) * x - 50 * w) for x, m, w in zip(
(2, 4, 6, 8, 10), map(int, input().split()), map(int, input().split())))
hs, hu = map(int, input().split())
print(res + hs * 100 - hu * 50)
if __name__ == '__main__':
main()
``` | output | 1 | 60,221 | 11 | 120,443 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. | instruction | 0 | 60,222 | 11 | 120,444 |
Tags: implementation
Correct Solution:
```
def score(value,time,wrongAnswer):
return max(.3*value,(1-time/250.0)*value-(50 * wrongAnswer))
def actualScore():
times=input().split()
times=list(map(int,times))
wrongAnswer=input().split()
wrongAnswer=list(map(int,wrongAnswer))
temp=input().split()
temp=list(map(int,temp))
total=0
for problem in range(len(times)):
total+=score(500*(problem+1),times[problem],wrongAnswer[problem])
total+=100*int(temp[0])
total-=50*int(temp[1])
return int(total)
print(actualScore())
``` | output | 1 | 60,222 | 11 | 120,445 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930.
Submitted Solution:
```
mi = map(int, input().split())
minutes = list(mi)
wr = map(int, input().split())
wrong = list(wr)
hs, hu = map(int, input().split())
max_point = [500, 1000, 1500, 2000, 2500]
score = 0
def Score_law(x, m, w) :
fir = 0.3 * x
sec = abs( ( (1 - (m / 250)) * x ) ) - (50 * w)
law = max(fir, sec)
return law
def getHacks(hs, hu) :
suc_hack = hs * 100
unsuc_hack = hu * 50
hack_score = suc_hack - unsuc_hack
return hack_score
for i in range(5) :
x = max_point[i]
m = minutes[i]
w = wrong[i]
score += Score_law(x, m, w)
hack_score = getHacks(hs, hu)
total_Score = int(score + hack_score)
print(total_Score)
``` | instruction | 0 | 60,223 | 11 | 120,446 |
Yes | output | 1 | 60,223 | 11 | 120,447 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930.
Submitted Solution:
```
def main():
minutos = [int(x) for x in input().split()]
erradas = [int(x) for x in input().split()]
Hs, Hf = [int(x) for x in input().split()]
x = [500, 1000, 1500, 2000, 2500]
soma = sum([max(0.3*x[i], (1 - minutos[i]/250)*x[i] - 50*erradas[i]) for i in range(5)])
score = soma + Hs*100 - Hf*50
print(int(score))
main()
``` | instruction | 0 | 60,224 | 11 | 120,448 |
Yes | output | 1 | 60,224 | 11 | 120,449 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930.
Submitted Solution:
```
def scanf():
inp = list(map(int, input().split(' ')))
if len(inp) == 1:
return inp[0]
return inp
m = scanf()
wa = scanf()
sh, uh = scanf()
score = sh * 100 + uh * (-50)
x = [500, 1000, 1500, 2000, 2500]
for i in range(5):
score += (max((0.3 * x[i]), ((1-m[i]/250)*x[i]) - 50*wa[i]))
print(int(score))
``` | instruction | 0 | 60,225 | 11 | 120,450 |
Yes | output | 1 | 60,225 | 11 | 120,451 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930.
Submitted Solution:
```
import sys
m = list(map(int,input().split()))
w = list(map(int,input().split()))
hs,hu = map(int,input().split())
point = [500,1000,1500,2000,2500]
res = 0
for i in range(5):
res += max(0.3*point[i],((1- (m[i]/250) )*point[i] - 50*w[i]))
res += hs*100 - hu*50
print(int(res))
``` | instruction | 0 | 60,226 | 11 | 120,452 |
Yes | output | 1 | 60,226 | 11 | 120,453 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930.
Submitted Solution:
```
m = list(map(int, input().split()))
w = list(map(int, input().split()))
h = list(map(int, input().split()))
x = sum([max(0.3 * x * 500, ((1 - (t / 250)) * x * 500) - (50 * a)) for x, t, a in zip(range(1, 6), m, w)]) + (
h[0] * 100) + (h[1] * 50)
print(int(x))
``` | instruction | 0 | 60,227 | 11 | 120,454 |
No | output | 1 | 60,227 | 11 | 120,455 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930.
Submitted Solution:
```
m = list(map(int, input().split()))
w = list(map(int, input().split()))
hs, hu = map(int, input().split())
s = 0
for i in range(5):
t = 500 * (i + 1)
s += max(0.3 * t, (1 - m[i] // 250) * t - 50 * w[i])
s += hs * 100 - hu * 50
print(s)
``` | instruction | 0 | 60,228 | 11 | 120,456 |
No | output | 1 | 60,228 | 11 | 120,457 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930.
Submitted Solution:
```
get_grade = lambda x, m, w:max( round(0.3*x), round((1 - m/250) * x - 50*w))
m1, m2, m3, m4, m5 = map(int, input().split(" "))
w1, w2, w3, w4, w5 = map(int, input().split(" "))
hs, hu = map(int, input().split(" "))
result = 100 * hs - 20 * hu
result += get_grade( 500, m1, w1)
result += get_grade( 1000, m2, w2)
result += get_grade( 1500, m3, w3)
result += get_grade( 2000, m4, w4)
result += get_grade( 2500, m5, w5)
print(result)
``` | instruction | 0 | 60,229 | 11 | 120,458 |
No | output | 1 | 60,229 | 11 | 120,459 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.
Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.
All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.
Input
The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 β€ mi β€ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.
The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 β€ wi β€ 10) is Kevin's number of wrong submissions on problem i.
The last line contains two space-separated integers hs and hu (0 β€ hs, hu β€ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.
Output
Print a single integer, the value of Kevin's final score.
Examples
Input
20 40 60 80 100
0 1 2 3 4
1 0
Output
4900
Input
119 119 119 119 119
0 0 0 0 0
10 0
Output
4930
Note
In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10Β·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930.
Submitted Solution:
```
m=[int(i) for i in input().split()]
w=[int(i) for i in input().split()]
h1,h2=map(int,input().split())
k=0
for i in range(5):
k+=max(0.3*(i+1)*500,round((1-m[i]/250)*(i+1)*500)-50*w[i])
k+=h1*100-h2*50
print(k)
``` | instruction | 0 | 60,230 | 11 | 120,460 |
No | output | 1 | 60,230 | 11 | 120,461 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N people numbered 1 to N. Each person wears a red hat or a blue hat.
You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`.
Determine if there are more people wearing a red hat than people wearing a blue hat.
Constraints
* 1 \leq N \leq 100
* |s| = N
* s_i is `R` or `B`.
Input
Input is given from Standard Input in the following format:
N
s
Output
If there are more people wearing a red hat than there are people wearing a blue hat, print `Yes`; otherwise, print `No`.
Examples
Input
4
RRBR
Output
Yes
Input
4
BRBR
Output
No
Submitted Solution:
```
a=int(input())
n=input()
print("Yes" if n.count("R")>n.count("B") else "No")
``` | instruction | 0 | 60,455 | 11 | 120,910 |
Yes | output | 1 | 60,455 | 11 | 120,911 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N people numbered 1 to N. Each person wears a red hat or a blue hat.
You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`.
Determine if there are more people wearing a red hat than people wearing a blue hat.
Constraints
* 1 \leq N \leq 100
* |s| = N
* s_i is `R` or `B`.
Input
Input is given from Standard Input in the following format:
N
s
Output
If there are more people wearing a red hat than there are people wearing a blue hat, print `Yes`; otherwise, print `No`.
Examples
Input
4
RRBR
Output
Yes
Input
4
BRBR
Output
No
Submitted Solution:
```
a = input()
b = input()
if b.count('R') > b.count('B'):
print('Yes')
else:
print('No')
``` | instruction | 0 | 60,456 | 11 | 120,912 |
Yes | output | 1 | 60,456 | 11 | 120,913 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.