message stringlengths 2 30.5k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 237 109k | cluster float64 10 10 | __index_level_0__ int64 474 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102. | instruction | 0 | 35,285 | 10 | 70,570 |
Tags: brute force, greedy, math
Correct Solution:
```
a, b, c, d, e, f = int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
k = 0
if f > e:
m = min(b, c, d)
d -= m
k = m*f
k += e*(min(a, d))
else:
m = min(a, d)
d -= m
k = m*e
k += f*(min(b, c, d))
print(k)
``` | output | 1 | 35,285 | 10 | 70,571 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102. | instruction | 0 | 35,286 | 10 | 70,572 |
Tags: brute force, greedy, math
Correct Solution:
```
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = int(input())
ans = 0
if (e > f):
n1 = min(a, d)
ans += n1 * e
d -= n1
n2 = min(d, min(b, c))
ans += n2 * f
else:
n2 = min(d, min(b, c))
ans += n2 * f
d -= n2
n1 = min(a, d)
ans += n1 * e
print(ans)
``` | output | 1 | 35,286 | 10 | 70,573 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102. | instruction | 0 | 35,287 | 10 | 70,574 |
Tags: brute force, greedy, math
Correct Solution:
```
def fr(a,b,c,d,e,f):
if e>f:
if d>a:
return min(d,a)*e+min(d-a,b,c)*f
else:
return min(d,a)*e
else:
if min(d,b,c)==d:
return min(b,c,d)*f
else:
return min(b,c)*f+min(d-min(b,c),a)*e
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
print((fr(a,b,c,d,e,f)))
``` | output | 1 | 35,287 | 10 | 70,575 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102. | instruction | 0 | 35,288 | 10 | 70,576 |
Tags: brute force, greedy, math
Correct Solution:
```
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = int(input())
if(e>=f):
n_e = min(a,d)
d -= n_e
n_f = min(b,c,d)
if(e<f):
n_f = min(b,c,d)
d -= n_f
n_e = min(a,d)
a -= n_e
d -= n_e
print(e*n_e+f*n_f)
``` | output | 1 | 35,288 | 10 | 70,577 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102. | instruction | 0 | 35,289 | 10 | 70,578 |
Tags: brute force, greedy, math
Correct Solution:
```
#import sys
#input = sys.stdin.readline
def main():
a = int( input())
b = int( input())
c = int( input())
d = int( input())
e = int( input())
f = int( input())
ans1 = min(a, d)*e;
if a < d:
ans1 += min(d-a, min(b, c))*f
ans2 = min(d, min(b, c))*f
if min(d, min(b, c)) < d:
ans2 += min(a, d - min(d, min(b, c)))*e
ans = max(ans1, ans2);
print(ans)
if __name__ == '__main__':
main()
``` | output | 1 | 35,289 | 10 | 70,579 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102. | instruction | 0 | 35,290 | 10 | 70,580 |
Tags: brute force, greedy, math
Correct Solution:
```
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = int(input())
if e>f:
m = min(a,d)
a = a-m
d = d-m
cost = e*m
m = min(b,c,d)
cost += f*m
print(cost)
else:
m = min(b,c,d)
b -= m
c -= m
d -= m
cost = f*m
m = min(a,d)
cost += e*m
print(cost)
``` | output | 1 | 35,290 | 10 | 70,581 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102. | instruction | 0 | 35,291 | 10 | 70,582 |
Tags: brute force, greedy, math
Correct Solution:
```
a = int(input())
b = int(input())
b = min(b, int(input()))
c = int(input())
d = int(input())
e = int(input())
res = max(d * i + e * min(c - i, b) for i in range(min(c, a) + 1))
print(res)
``` | output | 1 | 35,291 | 10 | 70,583 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102.
Submitted Solution:
```
a=int(input().strip())
b=int(input().strip())
c=int(input().strip())
d=int(input().strip())
e=int(input().strip())
f=int(input().strip())
q=e*min(d,a)+f*min(b,c,d-a)
w=e*min(d,a)
r=f*min(b,c,d)+e*min(d-min(b,c),a)
t=f*(min(b,c,d))
print(max(q,w,r,t))
``` | instruction | 0 | 35,292 | 10 | 70,584 |
Yes | output | 1 | 35,292 | 10 | 70,585 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102.
Submitted Solution:
```
t=int(input())
s=int(input())
v=int(input())
j=int(input())
e=int(input())
f=int(input())
u=min(s,v)
sum=0
if e==max(e,f):
sum+=e*min(t,j)
j-=min(t,j)
sum+=f*min(u,j)
else:
sum+=f*min(u,j)
j-=min(u,j)
sum+=e*min(t,j)
print(sum)
``` | instruction | 0 | 35,293 | 10 | 70,586 |
Yes | output | 1 | 35,293 | 10 | 70,587 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102.
Submitted Solution:
```
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = int(input())
b = min(b, c)
if e >= f:
if d <= a:
print(d * e)
else:
print(a * e + min(d - a, b) * f)
else:
if d <= b:
print(d * f)
else:
print(b * f + min(d - b, a) * e)
``` | instruction | 0 | 35,294 | 10 | 70,588 |
Yes | output | 1 | 35,294 | 10 | 70,589 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102.
Submitted Solution:
```
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
s1=[a,d]
s2=[b,c,d]
if(e>=f):
s2[2]=d-min(s1)
price=min(s1)*e+min(s2)*f
print(price)
else:
s1[1]=d-min(s2)
p=min(s2)*f+min(s1)*e
print(p)
``` | instruction | 0 | 35,295 | 10 | 70,590 |
Yes | output | 1 | 35,295 | 10 | 70,591 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102.
Submitted Solution:
```
ties, scarves, vests, jackets, suit_1_cost, suti_2_cost = [int(input()) for _ in range(6)]
if suit_1_cost <= suti_2_cost:
suit2_count = min(scarves, min(vests, jackets))
suit1_count = min(max(0, jackets - suit2_count), ties)
else:
suit1_count = min(scarves, min(vests, jackets))
suit2_count = min(max(0, jackets - suit1_count), ties)
print(suit2_count*suti_2_cost + suit_1_cost*suit1_count)
``` | instruction | 0 | 35,296 | 10 | 70,592 |
No | output | 1 | 35,296 | 10 | 70,593 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102.
Submitted Solution:
```
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = int(input())
counter = 0
if e > f:
while a != 0 and d != 0:
a -= 1
d -= 1
counter += e
while b != 0 and c != 0 and d != 0:
b -= 1
c -= 1
d -= 1
counter += f
elif f > e:
while b != 0 and c != 0 and d != 0:
b -= 1
c -= 1
d -= 1
counter += f
while a != 0 and d != 0:
a -= 1
d -= 1
counter += e
print(counter)
``` | instruction | 0 | 35,297 | 10 | 70,594 |
No | output | 1 | 35,297 | 10 | 70,595 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102.
Submitted Solution:
```
ties=int(input())
scarves=int(input())
vests=int(input())
jackets=int(input())
sc1=int(input())
sc2=int(input())
if(vests<jackets):
cost1=vests*sc1
else:
cost1=jackets*sc1
m=min(scarves,vests,jackets)
if(m==scarves):
cost2=scarves*sc2
elif(m==vests):
cost2=vests*sc2
else:
cost2=jackets*sc2
if(cost1<cost2):
x=jackets-m
if(x>0):
s=min(x,ties)*sc1
print(cost2+s)
else:
print(cost2);
else:
y=jackets-min(ties,jackets)
if(y<=0):
print(cost1)
else:
t=min(scarves,vests,y)*sc2
print(cost1+t)
``` | instruction | 0 | 35,298 | 10 | 70,596 |
No | output | 1 | 35,298 | 10 | 70,597 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first type consists of one tie and one jacket;
* a suit of the second type consists of one scarf, one vest and one jacket.
Each suit of the first type costs e coins, and each suit of the second type costs f coins.
Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).
Input
The first line contains one integer a (1 ≤ a ≤ 100 000) — the number of ties.
The second line contains one integer b (1 ≤ b ≤ 100 000) — the number of scarves.
The third line contains one integer c (1 ≤ c ≤ 100 000) — the number of vests.
The fourth line contains one integer d (1 ≤ d ≤ 100 000) — the number of jackets.
The fifth line contains one integer e (1 ≤ e ≤ 1 000) — the cost of one suit of the first type.
The sixth line contains one integer f (1 ≤ f ≤ 1 000) — the cost of one suit of the second type.
Output
Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.
Examples
Input
4
5
6
3
1
2
Output
6
Input
12
11
13
20
4
6
Output
102
Input
17
14
5
21
15
17
Output
325
Note
It is possible to compose three suits of the second type in the first example, and their total cost will be 6. Since all jackets will be used, it's impossible to add anything to this set.
The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is 9 ⋅ 4 + 11 ⋅ 6 = 102.
Submitted Solution:
```
#import sys
#import math
#sys.stdout=open("C:/Users/pipal/OneDrive/Desktop/VS code/python/output.txt","w")
#sys.stdin=open("C:/Users/pipal/OneDrive/Desktop/VS code/python/input.txt","r")
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
ans=0
if (e>f):
ans+=(e*min(a,d))
d=d-min(a,d)
min1=min(b,d)
min2=min(c,d)
mini=min(min1,min2)
ans+=(f*mini)
else:
l=[]
l.append(b)
l.append(c)
l.append(d)
ans+=(f*min(l))
d=d-min(l)
ans+=(f*min(a,d))
print(ans)
``` | instruction | 0 | 35,299 | 10 | 70,598 |
No | output | 1 | 35,299 | 10 | 70,599 |
Provide a correct Python 3 solution for this coding contest problem.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000 | instruction | 0 | 35,745 | 10 | 71,490 |
"Correct Solution:
```
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
print(sum(a[:k]))
``` | output | 1 | 35,745 | 10 | 71,491 |
Provide a correct Python 3 solution for this coding contest problem.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000 | instruction | 0 | 35,746 | 10 | 71,492 |
"Correct Solution:
```
N, K = map(int, input().split())
print(sum(sorted([int(a) for a in input().split()])[:K]))
``` | output | 1 | 35,746 | 10 | 71,493 |
Provide a correct Python 3 solution for this coding contest problem.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000 | instruction | 0 | 35,747 | 10 | 71,494 |
"Correct Solution:
```
x,y=map(int,input().split())
s=sorted(list(map(int,input().split())))
print(sum(s[:y]))
``` | output | 1 | 35,747 | 10 | 71,495 |
Provide a correct Python 3 solution for this coding contest problem.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000 | instruction | 0 | 35,748 | 10 | 71,496 |
"Correct Solution:
```
n,k = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
print(sum(p[:k]))
``` | output | 1 | 35,748 | 10 | 71,497 |
Provide a correct Python 3 solution for this coding contest problem.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000 | instruction | 0 | 35,749 | 10 | 71,498 |
"Correct Solution:
```
n, k = input().split()
p = list(map(int, input().split()))
p.sort()
print(sum(p[:int(k)]))
``` | output | 1 | 35,749 | 10 | 71,499 |
Provide a correct Python 3 solution for this coding contest problem.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000 | instruction | 0 | 35,750 | 10 | 71,500 |
"Correct Solution:
```
n,k=map(int,input().split())
print(sum(sorted(list(map(int,input().split())))[:k]))
``` | output | 1 | 35,750 | 10 | 71,501 |
Provide a correct Python 3 solution for this coding contest problem.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000 | instruction | 0 | 35,751 | 10 | 71,502 |
"Correct Solution:
```
N, K = map(int,input().split())
A = [int(x) for x in input().split()]
print(sum(sorted(A)[:K]))
``` | output | 1 | 35,751 | 10 | 71,503 |
Provide a correct Python 3 solution for this coding contest problem.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000 | instruction | 0 | 35,752 | 10 | 71,504 |
"Correct Solution:
```
N, K = map(int, input().split())
p = map(int, input().split())
print(sum(sorted(p)[:K]))
``` | output | 1 | 35,752 | 10 | 71,505 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000
Submitted Solution:
```
m,n=map(int,input().split())
l=list(map(int,input().split()))
print(sum(sorted(l)[:n]))
``` | instruction | 0 | 35,753 | 10 | 71,506 |
Yes | output | 1 | 35,753 | 10 | 71,507 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000
Submitted Solution:
```
k,n = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
print(sum(p[:n]))
``` | instruction | 0 | 35,754 | 10 | 71,508 |
Yes | output | 1 | 35,754 | 10 | 71,509 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000
Submitted Solution:
```
l=list(map(int,open(0).read().split()));print(sum(sorted(l[2:])[:l[1]]))
``` | instruction | 0 | 35,755 | 10 | 71,510 |
Yes | output | 1 | 35,755 | 10 | 71,511 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000
Submitted Solution:
```
N,K=list(map(int,input().split()))
p=list(map(int,input().split()))
p.sort()
print(sum(p[:K]))
``` | instruction | 0 | 35,756 | 10 | 71,512 |
Yes | output | 1 | 35,756 | 10 | 71,513 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000
Submitted Solution:
```
import itertools
import sys
from typing import Callable, NoReturn, Tuple
def main() -> NoReturn:
readline: Callable[[], str] = sys.stdin.readline
n, k = map(int, readline().rstrip().split()) # type: int,...
p: Tuple[int] = tuple(int(_) for _ in readline().rstrip().split())
if k < n // 2:
answer: int = 10 ** 6
for combinations in itertools.combinations(p, k):
sum_of_comb: int = sum(combinations)
if sum_of_comb < answer:
answer = sum_of_comb
else:
not_chosen: int = 0
for combinations in itertools.combinations(p, n - k):
sum_of_comb: int = sum(combinations)
if sum_of_comb > not_chosen:
not_chosen = sum_of_comb
answer: int = sum(p) - not_chosen
print(answer)
if __name__ == '__main__':
main()
``` | instruction | 0 | 35,757 | 10 | 71,514 |
No | output | 1 | 35,757 | 10 | 71,515 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000
Submitted Solution:
```
n, k = map(int, input().split())
ps = list(map(int, input().split()))
ps.sort()
ps[0:3]
print(sum(ps[0:3]))
``` | instruction | 0 | 35,758 | 10 | 71,516 |
No | output | 1 | 35,758 | 10 | 71,517 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000
Submitted Solution:
```
n, k = input().split(" ")
n = int(n)
k = int(k)
a = input().split(" ")
a = sorted(a)
ans = 0
for i in range(k):
ans += int(a[i])
print(ans)
``` | instruction | 0 | 35,759 | 10 | 71,518 |
No | output | 1 | 35,759 | 10 | 71,519 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
Constraints
* 1 \leq K \leq N \leq 1000
* 1 \leq p_i \leq 1000
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
p_1 p_2 \ldots p_N
Output
Print an integer representing the minimum possible total price of fruits.
Examples
Input
5 3
50 100 80 120 80
Output
210
Input
1 1
1000
Output
1000
Submitted Solution:
```
s = input().split()
intN = int(s[0])
intK = int(s[1])
inList = list(map(int,input().split()))
#print(inList)
inList.sort()
#print(inList)
idx = 0
intCnt = 0
for wInt in inList:
if (idx < 3) :
intCnt += wInt
#print(wInt)
#print(intCnt)
idx += 1
print(intCnt)
``` | instruction | 0 | 35,760 | 10 | 71,520 |
No | output | 1 | 35,760 | 10 | 71,521 |
Provide a correct Python 3 solution for this coding contest problem.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20 | instruction | 0 | 35,923 | 10 | 71,846 |
"Correct Solution:
```
while True:
n, m = map(int, input().split()) # 品物個数n, 最大の金額m
if n == 0:
break
A = list(map(int, input().split()))
# print(A)
ans = 0
for i in range(len(A)):
for j in range(i+1, len(A)):
if A[i] + A[j] > m:
continue
else:
ans = max(ans, A[i]+A[j])
if ans == 0:
print('NONE')
else:
print(ans)
``` | output | 1 | 35,923 | 10 | 71,847 |
Provide a correct Python 3 solution for this coding contest problem.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20 | instruction | 0 | 35,924 | 10 | 71,848 |
"Correct Solution:
```
while True:
(n, m) = tuple(map(int, input().split()))
if n == 0:
break
arr = list(map(int, input().split()))
arr.sort()
res = -1
for i, e in enumerate(arr[:-1]):
d = i + 1
if e + arr[i + 1] > m:
break
u = n
while u - d > 1:
medi = int((u + d) / 2)
if e + arr[medi] > m:
u = medi
else:
d = medi
res = max(res, e + arr[d])
if res < 0:
print("NONE")
else:
print(res)
``` | output | 1 | 35,924 | 10 | 71,849 |
Provide a correct Python 3 solution for this coding contest problem.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20 | instruction | 0 | 35,925 | 10 | 71,850 |
"Correct Solution:
```
ans=[]
n,m=map(int,input().split())
while n!=0 and m!=0:
a=[0]*n
a=list(input().split())
for i in range(n):
a[i]=int(a[i])
max=0
for i in range(n):
for j in range(n):
if i<j:
tmp=a[i]+a[j]
if tmp>max and tmp<=m:
max=tmp
else: pass
else: pass
ans.append(max)
n,m=map(int,input().split())
for i in range(len(ans)):
if ans[i]==0:
print("NONE")
else:
print(ans[i])
``` | output | 1 | 35,925 | 10 | 71,851 |
Provide a correct Python 3 solution for this coding contest problem.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20 | instruction | 0 | 35,926 | 10 | 71,852 |
"Correct Solution:
```
while True:
ans=[]
n,m = map(int,input().split())
if n==0 and m==0:
break
a = list(map(int,input().split()))
a = sorted(a)
b = 0
for i in range(n):
for j in range(i+1,n):
b = a[i]+a[j]
if b <= m:
ans.append(b)
else:
break
if len(ans)==0:
print("NONE")
else:
print(max(ans))
``` | output | 1 | 35,926 | 10 | 71,853 |
Provide a correct Python 3 solution for this coding contest problem.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20 | instruction | 0 | 35,927 | 10 | 71,854 |
"Correct Solution:
```
#!/usr/bin/env python3
while True:
n, m = map(int, input().split())
if n == 0:
exit()
a = list(map(int, input().split()))
ans = -1
for i in range(n):
for j in range(n):
if i == j: continue
s = a[i] + a[j]
if s <= m:
ans = max(ans, s)
print([ans, 'NONE'][ans == -1])
``` | output | 1 | 35,927 | 10 | 71,855 |
Provide a correct Python 3 solution for this coding contest problem.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20 | instruction | 0 | 35,928 | 10 | 71,856 |
"Correct Solution:
```
while True :
n, m = map(int, input().split())
if n == 0 and m == 0 :
break
catalog = list(map(int, input().split()))
max_p = 0
for i in range(n-1) :
for j in range(1, n) :
if i != j :
x = catalog[i] + catalog[j]
if x <= m and x > max_p :
max_p = x
if max_p == 0 :
print("NONE")
else :
print(max_p)
``` | output | 1 | 35,928 | 10 | 71,857 |
Provide a correct Python 3 solution for this coding contest problem.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20 | instruction | 0 | 35,929 | 10 | 71,858 |
"Correct Solution:
```
B=[]
while 1:
n,m=map(int,input().split())
if n==0 and m==0:
break
A=list(map(int,input().split()))
A.sort()
max=0
for i in range(n):
if A[i]>m:
break
for j in range(i+1,n):
sum=A[i]+A[j]
if sum>m:
break
elif sum>max:
max=sum
if max==0:
B.append("NONE")
else:
B.append(max)
for b in B:
print(b)
``` | output | 1 | 35,929 | 10 | 71,859 |
Provide a correct Python 3 solution for this coding contest problem.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20 | instruction | 0 | 35,930 | 10 | 71,860 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
while True:
n, m = map(int, input().split())
if n == 0:
break
a = sorted(list(map(int, input().split())), reverse=True)
ans = 0
for i in range(n):
for j in range(i+1, n):
tmp = a[i] + a[j]
if tmp <= m:
ans = max(ans, tmp)
if ans == 0:
print("NONE")
else:
print(ans)
``` | output | 1 | 35,930 | 10 | 71,861 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20
Submitted Solution:
```
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())
while True:
n,m = inpl()
if m == 0:
break
else:
aa = inpl()
aa.sort()
ans = -1
for i in range(n):
x = aa[i]
for j in range(n):
y = aa[j]
if i == j or x+y > m:
continue
ans = max(x+y,ans)
if ans == -1:
print('NONE')
else:
print(ans)
``` | instruction | 0 | 35,931 | 10 | 71,862 |
Yes | output | 1 | 35,931 | 10 | 71,863 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20
Submitted Solution:
```
while True:
(n,m) = map(int,input().split())
if n == 0 and m == 0:
break
iss = list(map(int, input().split()))
best = max([ (iss[i] + iss[j] if not ( i == j) and iss[i] + iss[j] <= m else -1) for i in range(0,n) for j in range(0,n) ])
if(best < 0):
print("NONE")
else:
print(best)
``` | instruction | 0 | 35,932 | 10 | 71,864 |
Yes | output | 1 | 35,932 | 10 | 71,865 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20
Submitted Solution:
```
import itertools
a=input().split()
cnt=0
ans=[]
while(True):
a=[int(i) for i in a]
b=input().split()
b=[int(i) for i in b]
c=list(itertools.combinations(b,2))
for i in range(len(c)):
if cnt<=c[i][0]+c[i][1] and c[i][0]+c[i][1]<=a[1]:
cnt=c[i][0]+c[i][1]
if cnt==0:
ans.append("NONE")
else:
ans.append(cnt)
a=input().split()
if(a[0]=='0' and a[1]=='0'):
break
cnt=0
for i in range(len(ans)):
print(ans[i])
``` | instruction | 0 | 35,933 | 10 | 71,866 |
Yes | output | 1 | 35,933 | 10 | 71,867 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20
Submitted Solution:
```
n,m=input().split()
n=(int)(n)
m=(int)(m)
B=[]
cnt=0
while n!=0 and m!=0:
A=input().split()
cnt=0
max=0
for i in range(n):
A[i]=(int)(A[i])
for i in range(n):
for j in range(i+1,n):
x=A[i]+A[j]
if x>max and x<=m:
max=x
if max>0:
B.append(max)
else:
B.append('NONE')
cnt+=1
n,m=input().split()
n=(int)(n)
m=(int)(m)
for i in range(len(B)):
print(B[i])
``` | instruction | 0 | 35,934 | 10 | 71,868 |
Yes | output | 1 | 35,934 | 10 | 71,869 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20
Submitted Solution:
```
while True:
t = 0
n,m = map(int,input().split())
if n != 0:
a = list(map(int,input().split()))
a.sort()
for i in range(n - 1):
k = a[-i-1]
for j in range(n - i):
if k + a[-i-1-j] <= m:
if k + a[-i-1-j] >= t:
t = k + a[-i-1-j]
break
if t == 0:
print("NONE")
else:
print(t)
else:
break
``` | instruction | 0 | 35,935 | 10 | 71,870 |
No | output | 1 | 35,935 | 10 | 71,871 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20
Submitted Solution:
```
s=[]
cnt=0
while 1:
n,m=map(int,input().split())
if n==0 and m==0:
break
a=list(int(i) for i in input().split())
max=0
for i in range(n):
for j in range(1,n-1):
c=a[i]+a[j]
if max<=c and c<=m:
max=c
if max==0:
s.append(0)
else:
s.append(max)
a=[0]
cnt=cnt+1
for i in range(cnt):
if s[i]==0:
print("none")
else:
print(s[i])
``` | instruction | 0 | 35,936 | 10 | 71,872 |
No | output | 1 | 35,936 | 10 | 71,873 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20
Submitted Solution:
```
maxs=[]
while(True):
max=0
b=list(map(int,input().split()))
n=b[0]
m=b[1]
if(n == 0 and m == 0):
break
a=list(map(int,input().split()))
for i in range(n):
for j in range(i+1,n):
sum=a[i]+a[j]
if(sum>max and sum<m):
max=sum
maxs.append(max)
for i in maxs:
if maxs[i]==0:
print("NONE")
else:
print(maxs[i])
``` | instruction | 0 | 35,937 | 10 | 71,874 |
No | output | 1 | 35,937 | 10 | 71,875 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Taro's Shopping
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items.
You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
Input
The input consists of multiple datasets, each in the following format.
n m
a1 a2 ... an
A dataset consists of two lines. In the first line, the number of items n and the maximum payment allowed m are given. n is an integer satisfying 2 ≤ n ≤ 1000. m is an integer satisfying 2 ≤ m ≤ 2,000,000. In the second line, prices of n items are given. ai (1 ≤ i ≤ n) is the price of the i-th item. This value is an integer greater than or equal to 1 and less than or equal to 1,000,000.
The end of the input is indicated by a line containing two zeros. The sum of n's of all the datasets does not exceed 50,000.
Output
For each dataset, find the pair with the highest price sum not exceeding the allowed amount m and output the sum in a line. If the price sum of every pair of items exceeds m, output `NONE` instead.
Sample Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output for the Sample Input
40
10
99
NONE
20
Example
Input
3 45
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
Output
40
10
99
NONE
20
Submitted Solution:
```
while(True):
n,m=map(int,input().split(" "))
if(n==0):
break
things = set(map(int,input().split(" ")))
_max=0
for i in things:
for j in things:
if(i!=j and i+j <= m and i+j>_max):
_max = i+j
if _max != None:
print(_max)
else:
print("NONE")
``` | instruction | 0 | 35,938 | 10 | 71,876 |
No | output | 1 | 35,938 | 10 | 71,877 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are two types of burgers in your restaurant — hamburgers and chicken burgers! To assemble a hamburger you need two buns and a beef patty. To assemble a chicken burger you need two buns and a chicken cutlet.
You have b buns, p beef patties and f chicken cutlets in your restaurant. You can sell one hamburger for h dollars and one chicken burger for c dollars. Calculate the maximum profit you can achieve.
You have to answer t independent queries.
Input
The first line contains one integer t (1 ≤ t ≤ 100) – the number of queries.
The first line of each query contains three integers b, p and f (1 ≤ b, ~p, ~f ≤ 100) — the number of buns, beef patties and chicken cutlets in your restaurant.
The second line of each query contains two integers h and c (1 ≤ h, ~c ≤ 100) — the hamburger and chicken burger prices in your restaurant.
Output
For each query print one integer — the maximum profit you can achieve.
Example
Input
3
15 2 3
5 10
7 5 2
10 12
1 100 100
100 100
Output
40
34
0
Note
In first query you have to sell two hamburgers and three chicken burgers. Your income is 2 ⋅ 5 + 3 ⋅ 10 = 40.
In second query you have to ell one hamburgers and two chicken burgers. Your income is 1 ⋅ 10 + 2 ⋅ 12 = 34.
In third query you can not create any type of burgers because because you have only one bun. So your income is zero. | instruction | 0 | 36,126 | 10 | 72,252 |
Tags: brute force, greedy, implementation, math
Correct Solution:
```
from math import *
from collections import *
from bisect import *
import sys
input=sys.stdin.readline
t=int(input())
while(t):
t-=1
#n=int(input())
b,f,c=map(int,input().split())
h,cc=map(int,input().split())
r=0
if(h>=cc):
re=min(b//2,f)
b-=re*2
r+=h*re
re=min(b//2,c)
b-=re*2
r+=cc*re
else:
re=min(b//2,c)
b-=re*2
r+=cc*re
re=min(b//2,f)
b-=re*2
r+=h*re
print(r)
``` | output | 1 | 36,126 | 10 | 72,253 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are two types of burgers in your restaurant — hamburgers and chicken burgers! To assemble a hamburger you need two buns and a beef patty. To assemble a chicken burger you need two buns and a chicken cutlet.
You have b buns, p beef patties and f chicken cutlets in your restaurant. You can sell one hamburger for h dollars and one chicken burger for c dollars. Calculate the maximum profit you can achieve.
You have to answer t independent queries.
Input
The first line contains one integer t (1 ≤ t ≤ 100) – the number of queries.
The first line of each query contains three integers b, p and f (1 ≤ b, ~p, ~f ≤ 100) — the number of buns, beef patties and chicken cutlets in your restaurant.
The second line of each query contains two integers h and c (1 ≤ h, ~c ≤ 100) — the hamburger and chicken burger prices in your restaurant.
Output
For each query print one integer — the maximum profit you can achieve.
Example
Input
3
15 2 3
5 10
7 5 2
10 12
1 100 100
100 100
Output
40
34
0
Note
In first query you have to sell two hamburgers and three chicken burgers. Your income is 2 ⋅ 5 + 3 ⋅ 10 = 40.
In second query you have to ell one hamburgers and two chicken burgers. Your income is 1 ⋅ 10 + 2 ⋅ 12 = 34.
In third query you can not create any type of burgers because because you have only one bun. So your income is zero. | instruction | 0 | 36,127 | 10 | 72,254 |
Tags: brute force, greedy, implementation, math
Correct Solution:
```
def cost(big):
global b
while big*2>b:
big-=1
b-=2*big
return big
for _ in range(int(input())):
b,p,f=map(int,input().split())
h,c=map(int,input().split())
if h<c:
ans=cost(f)*c+cost(p)*h
else:
ans=cost(p)*h+cost(f)*c
print(ans)
``` | output | 1 | 36,127 | 10 | 72,255 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are two types of burgers in your restaurant — hamburgers and chicken burgers! To assemble a hamburger you need two buns and a beef patty. To assemble a chicken burger you need two buns and a chicken cutlet.
You have b buns, p beef patties and f chicken cutlets in your restaurant. You can sell one hamburger for h dollars and one chicken burger for c dollars. Calculate the maximum profit you can achieve.
You have to answer t independent queries.
Input
The first line contains one integer t (1 ≤ t ≤ 100) – the number of queries.
The first line of each query contains three integers b, p and f (1 ≤ b, ~p, ~f ≤ 100) — the number of buns, beef patties and chicken cutlets in your restaurant.
The second line of each query contains two integers h and c (1 ≤ h, ~c ≤ 100) — the hamburger and chicken burger prices in your restaurant.
Output
For each query print one integer — the maximum profit you can achieve.
Example
Input
3
15 2 3
5 10
7 5 2
10 12
1 100 100
100 100
Output
40
34
0
Note
In first query you have to sell two hamburgers and three chicken burgers. Your income is 2 ⋅ 5 + 3 ⋅ 10 = 40.
In second query you have to ell one hamburgers and two chicken burgers. Your income is 1 ⋅ 10 + 2 ⋅ 12 = 34.
In third query you can not create any type of burgers because because you have only one bun. So your income is zero. | instruction | 0 | 36,128 | 10 | 72,256 |
Tags: brute force, greedy, implementation, math
Correct Solution:
```
def calculate_remaining_buns(b, n):
return b - 2*n if b - 2*n >= 0 else 0
def max_profit(b, p, f, h, c):
buns = b
profit = 0
if h > c:
buns = calculate_remaining_buns(b, p)
if buns > 0:
profit = p * h
remaining_buns = calculate_remaining_buns(buns, f)
if remaining_buns > 0:
profit += f * c
else:
profit += buns//2 * c
else:
profit = b//2 * h
else:
buns = calculate_remaining_buns(b, f)
if buns > 0:
profit = f * c
remaining_buns = calculate_remaining_buns(buns, p)
if remaining_buns > 0:
profit += p * h
else:
profit += buns//2 * h
else:
profit = b//2 * c
return profit
for _ in range(int(input())):
b, p, f = map(int, input().split())
h, c = map(int, input().split())
print(max_profit(b, p, f, h, c))
``` | output | 1 | 36,128 | 10 | 72,257 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.