message stringlengths 2 20.1k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 1.95k 109k | cluster float64 17 17 | __index_level_0__ int64 3.91k 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Stepan is a very experienced olympiad participant. He has n cups for Physics olympiads and m cups for Informatics olympiads. Each cup is characterized by two parameters — its significance ci and width wi.
Stepan decided to expose some of his cups on a shelf with width d in such a way, that:
* there is at least one Physics cup and at least one Informatics cup on the shelf,
* the total width of the exposed cups does not exceed d,
* from each subjects (Physics and Informatics) some of the most significant cups are exposed (i. e. if a cup for some subject with significance x is exposed, then all the cups for this subject with significance greater than x must be exposed too).
Your task is to determine the maximum possible total significance, which Stepan can get when he exposes cups on the shelf with width d, considering all the rules described above. The total significance is the sum of significances of all the exposed cups.
Input
The first line contains three integers n, m and d (1 ≤ n, m ≤ 100 000, 1 ≤ d ≤ 109) — the number of cups for Physics olympiads, the number of cups for Informatics olympiads and the width of the shelf.
Each of the following n lines contains two integers ci and wi (1 ≤ ci, wi ≤ 109) — significance and width of the i-th cup for Physics olympiads.
Each of the following m lines contains two integers cj and wj (1 ≤ cj, wj ≤ 109) — significance and width of the j-th cup for Informatics olympiads.
Output
Print the maximum possible total significance, which Stepan can get exposing cups on the shelf with width d, considering all the rules described in the statement.
If there is no way to expose cups on the shelf, then print 0.
Examples
Input
3 1 8
4 2
5 5
4 2
3 2
Output
8
Input
4 3 12
3 4
2 4
3 5
3 4
3 5
5 2
3 4
Output
11
Input
2 2 2
5 3
6 3
4 2
8 1
Output
0
Note
In the first example Stepan has only one Informatics cup which must be exposed on the shelf. Its significance equals 3 and width equals 2, so after Stepan exposes it, the width of free space on the shelf becomes equal to 6. Also, Stepan must expose the second Physics cup (which has width 5), because it is the most significant cup for Physics (its significance equals 5). After that Stepan can not expose more cups on the shelf, because there is no enough free space. Thus, the maximum total significance of exposed cups equals to 8.
Submitted Solution:
```
n, m, d = input().split()
n = int(n)
m = int(m)
d = int(d)
# c = {}
# w = {}
# topPhys = (0,-0) #cost, -width
# topInf = (0,-0)
phys = []
it = []
for i in range(0,n):
c, w = input().split()
c = int(c)
w = int(w)
phys.append([-c,w,'p'])
phys = sorted(phys)
for i in range(n,m+n):
c, w = input().split()
c = int(c)
w = int(w)
it.append([-c,w,'i'])
it = sorted(it)
curw = phys[0][1] + it[0][1]
curc = - phys[0][0] - it[0][0]
if (curw > d):
print(0)
quit()
phys[0][0] = 0
it[0][0] = 0
cup = []
cup.extend(phys)
cup.extend(it)
cup = sorted(cup)
# print("curc", curc)
# print("cups", cup)
phs = True
its = True
i = 0
while (phs and its and i < n+m):
if (curw + cup[i][1] > d):
if (cup[i][2] == 'i'):
its = False
else:
phs = False
else:
if (its and cup[i][2] == 'i') or (phs and cup[i][2] == 'p'):
curw += cup[i][1]
curc -= cup[i][0]
++i
print(curc)
``` | instruction | 0 | 101,687 | 17 | 203,374 |
No | output | 1 | 101,687 | 17 | 203,375 |
Provide a correct Python 3 solution for this coding contest problem.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even | instruction | 0 | 101,974 | 17 | 203,948 |
"Correct Solution:
```
h1, h2 = map(int, input().split())
k1, k2 = map(int, input().split())
a, b, c, d = map(int, input().split())
H = h1 * a + h2 * b + h1 // 10 * c + h2 // 20 * d
K = k1 * a + k2 * b + k1 // 10 * c + k2 // 20 * d
print('hiroshi' if H>K else 'even' if H==K else 'kenjiro')
``` | output | 1 | 101,974 | 17 | 203,949 |
Provide a correct Python 3 solution for this coding contest problem.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even | instruction | 0 | 101,975 | 17 | 203,950 |
"Correct Solution:
```
h1,h2 = [int(i) for i in input().split()]
k1,k2 = [int(i) for i in input().split()]
a,b,c,d = [int(i) for i in input().split()]
p1 = a*h1 + c*(h1 // 10) + b*h2 + d*(h2 // 20)
p2 = a*k1 + c*(k1 // 10) + b*k2 + d*(k2 // 20)
if p1 > p2:
print("hiroshi")
elif p1 < p2:
print("kenjiro")
else:
print("even")
``` | output | 1 | 101,975 | 17 | 203,951 |
Provide a correct Python 3 solution for this coding contest problem.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even | instruction | 0 | 101,976 | 17 | 203,952 |
"Correct Solution:
```
def getScore(i, y):
return i*a+y*b+c*(i//10)+d*(y//20)
h1, h2 = map(int, input().split())
k1, k2 = map(int, input().split())
a, b, c, d = map(int, input().split())
h, k = getScore(h1, h2), getScore(k1, k2)
if h>k:
print('hiroshi')
elif h<k:
print('kenjiro')
else:
print('even')
``` | output | 1 | 101,976 | 17 | 203,953 |
Provide a correct Python 3 solution for this coding contest problem.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even | instruction | 0 | 101,977 | 17 | 203,954 |
"Correct Solution:
```
h1, h2 = map(int, input().split())
k1, k2 = map(int, input().split())
a, b, c, d = map(int, input().split())
hiroshi = h1*a + h1//10*c + h2*b + h2//20*d
kenjiro = k1*a + k1//10*c + k2*b + k2//20*d
if hiroshi > kenjiro:
print("hiroshi")
elif hiroshi < kenjiro:
print("kenjiro")
else:
print("even")
``` | output | 1 | 101,977 | 17 | 203,955 |
Provide a correct Python 3 solution for this coding contest problem.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even | instruction | 0 | 101,978 | 17 | 203,956 |
"Correct Solution:
```
hi, hy = map(int, input().split())
ki, ky = map(int, input().split())
a, b, c, d = map(int, input().split())
h = hi * a + hi // 10 * c + hy * b + hy // 20 * d
k = ki * a + ki // 10 * c + ky * b + ky // 20 * d
if h > k: print("hiroshi")
elif h < k: print("kenjiro")
else: print("even")
``` | output | 1 | 101,978 | 17 | 203,957 |
Provide a correct Python 3 solution for this coding contest problem.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even | instruction | 0 | 101,979 | 17 | 203,958 |
"Correct Solution:
```
h1,h2=map(int,input().split())
k1,k2=map(int,input().split())
a,b,c,d=map(int,input().split())
hp=h1*a+h2*b+(h1//10)*c+(h2//20)*d
kp=k1*a+k2*b+(k1//10)*c+(k2//20)*d
if hp>kp:
print("hiroshi")
elif kp>hp:
print("kenjiro")
else:
print("even")
``` | output | 1 | 101,979 | 17 | 203,959 |
Provide a correct Python 3 solution for this coding contest problem.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even | instruction | 0 | 101,980 | 17 | 203,960 |
"Correct Solution:
```
h, i = map(int, input().split())
k, l = map(int, input().split())
a, b, c, d = map(int, input().split())
p = h * a + h // 10 * c + i * b + i // 20 * d
q = k * a + k // 10 * c + l * b + l // 20 * d
if p == q:print("even")
else:print("hiroshi" if p > q else "kenjiro")
``` | output | 1 | 101,980 | 17 | 203,961 |
Provide a correct Python 3 solution for this coding contest problem.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even | instruction | 0 | 101,981 | 17 | 203,962 |
"Correct Solution:
```
#標準入力
ha,hb = map(int,input().split())
ka,kb = map(int,input().split())
a,b,c,d = map(int,input().split())
ht,kt = 0,0
#得点の計算
ht = ha * a + hb * b + (ha // 10) * c + (hb // 20) * d
kt = ka * a + kb * b + (ka // 10) * c + (kb // 20) * d
#得点が大きいほう、または引き分けを出力する
if ht > kt:print("hiroshi")
elif ht < kt:print("kenjiro")
elif ht == kt:print("even")
``` | output | 1 | 101,981 | 17 | 203,963 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even
Submitted Solution:
```
h1, h2 = list(map(int, input().split()))
k1, k2 = list(map(int, input().split()))
a,b,c,d = list(map(int, input().split()))
hiro = h1*a + h2*b + (h1//10)*c + (h2//20)*d
ken = k1*a + k2*b + (k1//10)*c + (k2//20)*d
if hiro>ken:
print('hiroshi')
elif ken>hiro:
print('kenjiro')
else:
print('even')
``` | instruction | 0 | 101,982 | 17 | 203,964 |
Yes | output | 1 | 101,982 | 17 | 203,965 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even
Submitted Solution:
```
[h1, h2] = [int(num) for num in input().split()]
[k1, k2] = [int(num) for num in input().split()]
[a, b, c, d] = [int(num) for num in input().split()]
counth = a * h1 + b * h2 + c * (h1 // 10) + d * (h2 // 20)
countk = a * k1 + b * k2 + c * (k1 // 10) + d * (k2 // 20)
if (counth > countk):
print('hiroshi')
elif (counth < countk):
print('kenjiro')
else:
print('even')
``` | instruction | 0 | 101,983 | 17 | 203,966 |
Yes | output | 1 | 101,983 | 17 | 203,967 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even
Submitted Solution:
```
h,i = map(int,input().split(" "))
k,j = map(int,input().split(" "))
a,b,c,d = map(int,input().split(" "))
s=h*a+i*b+(h//10)*c+(i//20)*d
r=k*a+j*b+(k//10)*c+(j//20)*d
if s > r:
print("hiroshi")
elif s == r:
print("even")
else:
print("kenjiro")
``` | instruction | 0 | 101,984 | 17 | 203,968 |
Yes | output | 1 | 101,984 | 17 | 203,969 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even
Submitted Solution:
```
h1, h2 = map(int,input().split())
k1, k2 = map(int,input().split())
a, b, c, d = map(int,input().split())
if h1 > 9:
hn = int(h1/10)
else:
hn = 0
if h2 > 19:
hm = int(h1/20)
else:
hm = 0
if k1 > 9:
kn = int(k1/10)
else:
kn = 0
if k2 > 19:
km = int(k2/20)
else:
km = 0
h = h1*a + hn*c + h2*b + hm*d
k = k1*a + kn*c + k2*b + km*d
if h<k:
print("kenjiro")
elif k<h:
print("hiroshi")
elif h == k:
print("even")
``` | instruction | 0 | 101,985 | 17 | 203,970 |
Yes | output | 1 | 101,985 | 17 | 203,971 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even
Submitted Solution:
```
h1, h2 = map(int, input().split())
k1, k2 = map(int, input().split())
a, b, c, d = map(int, input().split())
H = h1 * a + h2 * b + h1 // 10 * c + h2 // 10 * d
K = k1 * a + k2 * b + k1 // 10 * c + k2 // 10 * d
print('hiroshi' if H>K else 'even' if H==K else 'kenjiro')
``` | instruction | 0 | 101,986 | 17 | 203,972 |
No | output | 1 | 101,986 | 17 | 203,973 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even
Submitted Solution:
```
h1,h2 = map(int,input().split())
k1,k2 = map(int,input().split())
a,b,c,d = map(int,input().split())
def f(x,y):
return a*x + b*y + c*(x//10) + d*(y//10)
H,K = f(h1,h2), f(k1,k2)
ans = 'even'
if H>K:
ans = 'hiroshi'
elif H<K:
ans = 'kenjiro'
print(ans)
``` | instruction | 0 | 101,987 | 17 | 203,974 |
No | output | 1 | 101,987 | 17 | 203,975 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even
Submitted Solution:
```
h, i = map(int, input().split())
k, l = map(int, input().split())
a, b, c, d = map(int, input().split())
p = h * a + h // 10 * c + i * b + i // 10 * d
q = k * a + k // 10 * c + l * b + l // 10 * d
if p == q:print("even")
else:print("hiroshi" if p > q else "kenjiro")
``` | instruction | 0 | 101,988 | 17 | 203,976 |
No | output | 1 | 101,988 | 17 | 203,977 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.
* One char is a point
* One yamame trout b points
* Add c points for every 10 chars
* Add d points for every 20 yamame trout
Create a program to determine which one wins or draws based on the number of fish caught by Hiroshi and Kenjiro.
Input
The input is given in the following format.
h1 h2
k1 k2
a b c d
The first line gives the number of chars h1 (0 ≤ h1 ≤ 100) and the number of yamame trout h2 (0 ≤ h2 ≤ 100) caught by Hiroshi. The second line gives the number of chars k1 (0 ≤ k1 ≤ 100) and the number of yamame trout k2 (0 ≤ k2 ≤ 100) caught by Kenjiro. On the third line, the score for each char is a (1 ≤ a ≤ 100), the score for each yamame trout is b (1 ≤ b ≤ 100), and the additional score for every 10 chars is c (0 ≤ c ≤ 100). ), An additional score d (0 ≤ d ≤ 100) is given for every 20 chars.
Output
If Hiro wins, hiroshi, if Kenjiro wins, kenjiro, and if a tie, even, output on one line.
Examples
Input
5 1
3 1
1 2 5 5
Output
hiroshi
Input
5 1
4 2
1 2 5 5
Output
kenjiro
Input
0 20
10 0
1 1 10 0
Output
even
Submitted Solution:
```
h1,h2=map(int,input().split())
k1,k2=map(int,input().split())
a,b,c,d=map(int,input().split())
e,f,g,h=h1*a,h2*b,k1*a,k2*b
o,n,m,v=h1//10*c,h2//10*d,k1//10*c,k2//10*d
z,y=o+n+e+f,m+v+g+h
if z>y:
print("hiroshi")
elif z<y:
print("kenjiro")
else:
print("even")
``` | instruction | 0 | 101,989 | 17 | 203,978 |
No | output | 1 | 101,989 | 17 | 203,979 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students. | instruction | 0 | 102,120 | 17 | 204,240 |
Tags: math
Correct Solution:
```
q = int(input())
for queries in range(q):
n = int(input())
skill = list(map(int, input().split()))
skill.sort()
times = 1
for i in range(len(skill) - 1):
if skill[i + 1] - skill[i] == 1:
times = 2
print(times)
``` | output | 1 | 102,120 | 17 | 204,241 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students. | instruction | 0 | 102,121 | 17 | 204,242 |
Tags: math
Correct Solution:
```
q=int(input())
for i in range(q):
n=int(input())
a=list(map(int,input().split()))
grp=1
for j in range(n):
if a[j]-1 in a or a[j]+1 in a:
grp=2
break
print(grp)
``` | output | 1 | 102,121 | 17 | 204,243 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students. | instruction | 0 | 102,122 | 17 | 204,244 |
Tags: math
Correct Solution:
```
t=int(input())
for i in range(t):
n=int(input());c=0;y=[]
x=list(map(int,input().split()))
y=sorted(x)
#print(y)
for j in range(len(y)-1):
#print(j+1," hj ",j)
#print(y[j+1]," hj ",y[j])
if ((abs(y[j+1]-y[j]))==1):
c+=1
y[j+1]=0
#del y[j+1]
#del y[j]
if c==0:
print(1)
else:
print(2)
y.clear()
``` | output | 1 | 102,122 | 17 | 204,245 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students. | instruction | 0 | 102,123 | 17 | 204,246 |
Tags: math
Correct Solution:
```
t = int(input())
for _ in range(t):
n, ok = int(input()), 0
a = list(map(int, input().split()))
a.sort()
for i in range(0, n-1):
if a[i+1] - a[i] == 1:
ok = 1
print([1, 2][ok])
``` | output | 1 | 102,123 | 17 | 204,247 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students. | instruction | 0 | 102,124 | 17 | 204,248 |
Tags: math
Correct Solution:
```
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
f = 0
for i in a:
if i+1 in a:
f = 1
break
if f:
print(2)
else:
print(1)
``` | output | 1 | 102,124 | 17 | 204,249 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students. | instruction | 0 | 102,125 | 17 | 204,250 |
Tags: math
Correct Solution:
```
q = int(input())
n=[0]*q
answer=[1]*q
for i in range(q):
n[i]=int(input())
a= [int(x) for x in input().split()]
# решаем может быть одна команда или 2. при каком условии может быть 3 команды? в одну все четные, в другую нечетные.
for j in range(n[i]):
for k in range(j+1,n[i]):
if (abs(a[j]-a[k])==1):
answer[i]=2
break
else:
continue
break
for i in answer:
print(i)
``` | output | 1 | 102,125 | 17 | 204,251 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students. | instruction | 0 | 102,126 | 17 | 204,252 |
Tags: math
Correct Solution:
```
t=int(input());
for i in range(t):
m=int(input());
n=input();
n=n.split();
for j in range(m):
n[j]=int(n[j]);
n.sort();
counter=0;
for j in range(1,m):
if(n[j]-n[j-1]<=1):
counter+=1;
if(counter==0):
print(1);
else:
print(2);
``` | output | 1 | 102,126 | 17 | 204,253 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students. | instruction | 0 | 102,127 | 17 | 204,254 |
Tags: math
Correct Solution:
```
q = int(input())
for test in range(q):
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = False
for i in range(n - 1):
if a[i + 1] - a[i] == 1:
ans = True
if ans == True:
print(2)
else:
print(1)
``` | output | 1 | 102,127 | 17 | 204,255 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students.
Submitted Solution:
```
for _ in range(int(input())):
x=int(input())
s=sorted(list(map(int,input().split())))
even=[]
odd=[]
indicator=0
for n in range(x):
if s[n]%2==0:
even.append(s[n])
else:
odd.append(s[n])
for n in even:
if (n+1) in odd:
indicator=1
break
elif (n-1) in odd:
indicator=1
break
else:
indicator=0
if indicator==1:
print(2)
else:
print(1)
``` | instruction | 0 | 102,128 | 17 | 204,256 |
Yes | output | 1 | 102,128 | 17 | 204,257 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students.
Submitted Solution:
```
T= int(input())
while(T>0):
N=int(input())
a=[int(x) for x in input().split()]
a.sort()
f=a[0]
c=0
for i in range(1,len(a)):
if abs(a[i]-f)==1:
c+=1
f=a[i]
if c>0:
print(2)
else:
print(1)
T=T-1
``` | instruction | 0 | 102,129 | 17 | 204,258 |
Yes | output | 1 | 102,129 | 17 | 204,259 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students.
Submitted Solution:
```
q=int(input())
for j in range(q):
n=int(input())
ch=input()
L=ch.split()
for i in range(n):
L[i] = int(L[i])
L.sort()
nb=1
for i in range(n-1):
if L[i+1]-L[i]==1:
nb=2
break
print(nb)
``` | instruction | 0 | 102,130 | 17 | 204,260 |
Yes | output | 1 | 102,130 | 17 | 204,261 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students.
Submitted Solution:
```
t=int(input())
for i in range(t):
n=int(input())
c=1
a=list(map(int,input().split()))[:n]
for i in range(len(a)):
for j in range(i,len(a)):
if abs(a[i]-a[j])==1:
c=c+1
if c>2:
print(2)
else:
print(c)
``` | instruction | 0 | 102,131 | 17 | 204,262 |
Yes | output | 1 | 102,131 | 17 | 204,263 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students.
Submitted Solution:
```
t=int(input())
for _ in range(t):
n=int(input())
a=list(map(int,input().split()))
a.sort()
c=0
for i in range(n-1):
if abs(a[i]-a[i+1])==1:
c=-1
if c==0:
print(2)
else:
print(1)
``` | instruction | 0 | 102,132 | 17 | 204,264 |
No | output | 1 | 102,132 | 17 | 204,265 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students.
Submitted Solution:
```
#!/usr/bin/env python
# coding: utf-8
# In[6]:
q=int(input())
ans=[]
for i in range(0,q):
n=int(input())
s=input().split()
if len(s)==1:
ans.append(1)
else:
a=int(s[0])
for i in s:
c=0
x=abs(a-int(i))
if x==1:
break
else :
c+=1;
if c==0:
ans.append(2)
else:
ans.append(1)
for i in ans:
print(i)
# In[ ]:
``` | instruction | 0 | 102,133 | 17 | 204,266 |
No | output | 1 | 102,133 | 17 | 204,267 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students.
Submitted Solution:
```
q=int(input())
ans=[]
for i in range(0,q):
n=int(input())
s=input().split()
a=int(s[0])
for i in s:
c=0
x=abs(a-int(i))
if x==1:
break
else :
c+=1;
if c==0:
ans.append(2)
else:
ans.append(1)
for i in ans:
print(i)
ans.clear()
``` | instruction | 0 | 102,134 | 17 | 204,268 |
No | output | 1 | 102,134 | 17 | 204,269 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 belong to the same team (i.e. skills of each pair of students in the same team have the difference strictly greater than 1);
* the number of teams is the minimum possible.
You have to answer q independent queries.
Input
The first line of the input contains one integer q (1 ≤ q ≤ 100) — the number of queries. Then q queries follow.
The first line of the query contains one integer n (1 ≤ n ≤ 100) — the number of students in the query. The second line of the query contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100, all a_i are distinct), where a_i is the programming skill of the i-th student.
Output
For each query, print the answer on it — the minimum number of teams you can form if no two students i and j such that |a_i - a_j| = 1 may belong to the same team (i.e. skills of each pair of students in the same team has the difference strictly greater than 1)
Example
Input
4
4
2 10 1 20
2
3 6
5
2 3 4 99 100
1
42
Output
2
1
2
1
Note
In the first query of the example, there are n=4 students with the skills a=[2, 10, 1, 20]. There is only one restriction here: the 1-st and the 3-th students can't be in the same team (because of |a_1 - a_3|=|2-1|=1). It is possible to divide them into 2 teams: for example, students 1, 2 and 4 are in the first team and the student 3 in the second team.
In the second query of the example, there are n=2 students with the skills a=[3, 6]. It is possible to compose just a single team containing both students.
Submitted Solution:
```
def main():
q = int(input())
for i in range(q):
n = int(input())
l = input().split()
count = 0
while (len(l) > 0):
tmp = 1
while tmp < len(l):
#print(l[0], l[tmp])
if (abs(int(l[0]) - int(l[tmp])) > 1):
l.pop(tmp)
else:
tmp += 1
l.pop(0)
count += 1
#print(l)
print(count)
if __name__ == '__main__':
main()
``` | instruction | 0 | 102,135 | 17 | 204,270 |
No | output | 1 | 102,135 | 17 | 204,271 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one. | instruction | 0 | 103,715 | 17 | 207,430 |
Tags: sortings
Correct Solution:
```
n = int(input())
a = [int(i) for i in input().split()]
ct = 0
a = sorted(a)
i = 0
while i < n-1:
ct += a[i+1] - a[i]
i += 2
print(ct)
``` | output | 1 | 103,715 | 17 | 207,431 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one. | instruction | 0 | 103,716 | 17 | 207,432 |
Tags: sortings
Correct Solution:
```
import math
for _ in range(1):
n=int(input())
l1=list(map(int,input().split()))
l1.sort()
c=0
for i in range(0,n-1,2):
c=c+abs(l1[i]-l1[i+1])
print(c)
``` | output | 1 | 103,716 | 17 | 207,433 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one. | instruction | 0 | 103,717 | 17 | 207,434 |
Tags: sortings
Correct Solution:
```
n = int(input())
skills = list(map(int, input().split()))
t = n//2
skills.sort()
topSkills = []
for i in range(n//2):
topSkills.append([skills[-1]]+[skills[-2]])
skills = skills[:-2]
sum = 0
for i in topSkills:
sum += abs(i[0]-i[1])
print(sum)
``` | output | 1 | 103,717 | 17 | 207,435 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one. | instruction | 0 | 103,718 | 17 | 207,436 |
Tags: sortings
Correct Solution:
```
def closest(lst, K):
return lst[min(range(len(lst)), key = lambda i: abs(lst[i]-K))]
def int_put():
num_list = input("").split()
return [int(input) for input in num_list]
st_num = int(input(""))
skill_list = int_put()
skill_list.sort()
#go through the list find the nearest number to what the current index is
#increment it if need be so it's == to curr
ex_num = 0
def find_ex_num(skill_li):
global ex_num
if(len(skill_li) == 0):
return
curr_skill = skill_li[0]
skill_li.remove(curr_skill)
closest_num = closest(skill_li, curr_skill)
skill_li.remove(closest_num)
if(closest_num == curr_skill):
return find_ex_num(skill_li)
else:
ex_num += abs(closest_num - curr_skill)
return find_ex_num(skill_li)
find_ex_num(skill_list)
print(ex_num)
``` | output | 1 | 103,718 | 17 | 207,437 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one. | instruction | 0 | 103,719 | 17 | 207,438 |
Tags: sortings
Correct Solution:
```
n=int(input())
a=sorted(list(map(int,input().split())))
ans=0
for i in range(0,n,2):
ans+=a[i+1]-a[i]
print(ans)
``` | output | 1 | 103,719 | 17 | 207,439 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one. | instruction | 0 | 103,720 | 17 | 207,440 |
Tags: sortings
Correct Solution:
```
n = int(input())
pupils = list(map(int, input().split()))
pupils.sort()
tasks = 0
for i in range(0, n, 2):
tasks += pupils[i + 1] - pupils[i]
print(tasks)
``` | output | 1 | 103,720 | 17 | 207,441 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one. | instruction | 0 | 103,721 | 17 | 207,442 |
Tags: sortings
Correct Solution:
```
n = int(input())
l = list(map(int,input().split()))
l.sort()
s1 = 0
s2 = 0
for i in range(0,n,2):
s1 += l[i]
for i in range(1,n,2):
s2 += l[i]
print(s2-s1)
``` | output | 1 | 103,721 | 17 | 207,443 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one. | instruction | 0 | 103,722 | 17 | 207,444 |
Tags: sortings
Correct Solution:
```
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
s=0
for i in range(n-1):
x=i+1
for j in range(i+1, n):
if abs(a[x]-a[i])>abs(a[j]-a[i]) and a[j]!=-1 and a[i]!=-1:
x=j
if a[x]!=-1 and a[i]!=-1:
s+=abs(a[x]-a[i])
a[x]=-1
print(s)
``` | output | 1 | 103,722 | 17 | 207,445 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one.
Submitted Solution:
```
n = eval(input())
line = input()
strings = line.split()
list = []
for string in strings:
list.append(eval(string))
sortedList = sorted(list)
size = len(list)
pn=0
for k in range(0, size, 2):
pn += abs(sortedList[k] - sortedList[k+1])
print(pn)
``` | instruction | 0 | 103,723 | 17 | 207,446 |
Yes | output | 1 | 103,723 | 17 | 207,447 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one.
Submitted Solution:
```
n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
ans = 0
for i in range(0,n,2):
ans+=arr[i+1]-arr[i]
print(ans)
``` | instruction | 0 | 103,724 | 17 | 207,448 |
Yes | output | 1 | 103,724 | 17 | 207,449 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one.
Submitted Solution:
```
n=int(input())
list=[int(i) for i in input().strip().split(' ')]
sum=0
list.sort()
for i in range(0,len(list)-1,2):
sum+=list[i+1]-list[i]
print(sum)
``` | instruction | 0 | 103,725 | 17 | 207,450 |
Yes | output | 1 | 103,725 | 17 | 207,451 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one.
Submitted Solution:
```
if __name__ == '__main__':
n = int(input().strip())
students = [s for s in map(int, input().strip().split())]
for i in range(n):
for j in range(n-i-1):
if students[j] > students[j+1]:
t = students[j]
students[j] = students[j+1]
students[j+1] = t
acc = 0
for i in range(0, n, 2):
acc += abs(students[i] - students[i+1])
print(acc)
# print(students)
``` | instruction | 0 | 103,726 | 17 | 207,452 |
Yes | output | 1 | 103,726 | 17 | 207,453 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one.
Submitted Solution:
```
n=int(input())
arr=list(map(int,input().split()))
arr.sort()
c=0
for i in range(len(arr)-1):
c+=arr[i+1]-arr[i]
print(c)
``` | instruction | 0 | 103,727 | 17 | 207,454 |
No | output | 1 | 103,727 | 17 | 207,455 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one.
Submitted Solution:
```
n= int(input())
list1= input().split()
length=len(list1)
half=int(length/2)
sum1=0
sum2=0
for i in range(0,half):
list1[i]=int(list1[i])
sum1=sum1+list1[i]
for j in range(half,length):
list1[j]=int(list1[j])
sum2=sum2+list1[j]
diff=abs(sum1-sum2)
if(diff==298):
diff=60
elif(diff==84):
diff=0
elif(diff==546):
diff=50
elif(diff>100):
diff=0
print(diff)
``` | instruction | 0 | 103,728 | 17 | 207,456 |
No | output | 1 | 103,728 | 17 | 207,457 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one.
Submitted Solution:
```
numOfStudents = int(input())
students = input().split()
student = int(students[0])
tasksNeed = 0
for i in range(1, numOfStudents):
if int(students[i]) < student:
student, int(students[i]) == int(students[i]), student
student = int(students[i])
for i in range(0, numOfStudents - 1, 2):
if int(students[i]) != int(students[i + 1]):
minNumber = min(int(students[i]), int(students[i + 1]))
maxNumber = max(int(students[i]), int(students[i + 1]))
while minNumber != maxNumber:
minNumber += 1
tasksNeed += 1
print(tasksNeed)
``` | instruction | 0 | 103,729 | 17 | 207,458 |
No | output | 1 | 103,729 | 17 | 207,459 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i.
The coach wants to form n/2 teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).
Students can solve problems to increase their skill. One solved problem increases the skill by one.
The coach wants to know the minimum total number of problems students should solve to form exactly n/2 teams (i.e. each pair of students should form a team). Your task is to find this number.
Input
The first line of the input contains one integer n (2 ≤ n ≤ 100) — the number of students. It is guaranteed that n is even.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the skill of the i-th student.
Output
Print one number — the minimum total number of problems students should solve to form exactly n/2 teams.
Examples
Input
6
5 10 2 3 14 5
Output
5
Input
2
1 100
Output
99
Note
In the first example the optimal teams will be: (3, 4), (1, 6) and (2, 5), where numbers in brackets are indices of students. Then, to form the first team the third student should solve 1 problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve 4 problems so the answer is 1 + 4 = 5.
In the second example the first student should solve 99 problems to form a team with the second one.
Submitted Solution:
```
#1092B Team forming
n=int(input())
a=[int(x) for x in input().split()]
a.sort()
count=0
for i in range(n-1):
count=count+(a[i+1]-a[i])
i+=1
print(count)
``` | instruction | 0 | 103,730 | 17 | 207,460 |
No | output | 1 | 103,730 | 17 | 207,461 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Soon a school Olympiad in Informatics will be held in Berland, n schoolchildren will participate there.
At a meeting of the jury of the Olympiad it was decided that each of the n participants, depending on the results, will get a diploma of the first, second or third degree. Thus, each student will receive exactly one diploma.
They also decided that there must be given at least min1 and at most max1 diplomas of the first degree, at least min2 and at most max2 diplomas of the second degree, and at least min3 and at most max3 diplomas of the third degree.
After some discussion it was decided to choose from all the options of distributing diplomas satisfying these limitations the one that maximizes the number of participants who receive diplomas of the first degree. Of all these options they select the one which maximizes the number of the participants who receive diplomas of the second degree. If there are multiple of these options, they select the option that maximizes the number of diplomas of the third degree.
Choosing the best option of distributing certificates was entrusted to Ilya, one of the best programmers of Berland. However, he found more important things to do, so it is your task now to choose the best option of distributing of diplomas, based on the described limitations.
It is guaranteed that the described limitations are such that there is a way to choose such an option of distributing diplomas that all n participants of the Olympiad will receive a diploma of some degree.
Input
The first line of the input contains a single integer n (3 ≤ n ≤ 3·106) — the number of schoolchildren who will participate in the Olympiad.
The next line of the input contains two integers min1 and max1 (1 ≤ min1 ≤ max1 ≤ 106) — the minimum and maximum limits on the number of diplomas of the first degree that can be distributed.
The third line of the input contains two integers min2 and max2 (1 ≤ min2 ≤ max2 ≤ 106) — the minimum and maximum limits on the number of diplomas of the second degree that can be distributed.
The next line of the input contains two integers min3 and max3 (1 ≤ min3 ≤ max3 ≤ 106) — the minimum and maximum limits on the number of diplomas of the third degree that can be distributed.
It is guaranteed that min1 + min2 + min3 ≤ n ≤ max1 + max2 + max3.
Output
In the first line of the output print three numbers, showing how many diplomas of the first, second and third degree will be given to students in the optimal variant of distributing diplomas.
The optimal variant of distributing diplomas is the one that maximizes the number of students who receive diplomas of the first degree. Of all the suitable options, the best one is the one which maximizes the number of participants who receive diplomas of the second degree. If there are several of these options, the best one is the one that maximizes the number of diplomas of the third degree.
Examples
Input
6
1 5
2 6
3 7
Output
1 2 3
Input
10
1 2
1 3
1 5
Output
2 3 5
Input
6
1 3
2 2
2 2
Output
2 2 2 | instruction | 0 | 104,041 | 17 | 208,082 |
Tags: greedy, implementation, math
Correct Solution:
```
import sys
n = int(input())
min1, max1 = map(int, input().split(" "))
min2, max2 = map(int, input().split(" "))
min3, max3 = map(int, input().split(" "))
a1 = a2 = a3 = 0
a3 = min3
a2 = min2
a1 = min1
rem = n - (a1 + a2 + a3)
if rem >= max1 - a1:
rem-=(max1-a1)
a1 = max1
if(rem == 0):
print(str(a1) + " " + str(a2) + " " + str(a3))
sys.exit(0)
else:
if rem >= max2 - a2:
rem -= max2-a2
a2 = max2
if rem == 0:
print(str(a1) + " " + str(a2) + " " + str(a3))
sys.exit(0)
else:
a3 += rem
print(str(a1) + " " + str(a2) + " " + str(a3))
sys.exit(0)
else:
a2+= rem
print(str(a1) + " " + str(a2) + " " + str(a3))
sys.exit(0)
else:
a1+=rem
print(str(a1) + " " + str(a2) + " " + str(a3))
``` | output | 1 | 104,041 | 17 | 208,083 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.