#P6443. [COCI 2010/2011 #1] TIMSKO

[COCI 2010/2011 #1] TIMSKO

Description

A university holds an informatics contest every year. In the contest, each team consists of 11 boy and 22 girls. In order to reduce the number of opponents, a dean of a faculty arranges for some opponents to go to an internship in a faraway country, and those sent to the internship will not be able to participate in the contest. Among all contestants, the number of female contestants is mm, the number of male contestants is nn, and the number of opponents that can be sent to the internship is kk. The dean must form teams that can participate in the contest. Your task is to output the maximum number of teams that can be formed.

Input Format

The input consists of one line.

One line with three integers m,n,km, n, k, with the meanings as described above.

Output Format

The output consists of one line.

One line with one integer ansans, indicating the maximum number of teams that can be formed.

6 3 2
2
2 1 1
0
6 10 3
3

Hint

Explanation for Sample Input/Output 1

The dean can send one boy and one girl to the internship. Then it becomes: m=5m=5, n=2n=2. Two teams can be formed (one girl has no team), so the answer is 22.


Constraints

For 100%100\% of the testdata, 0n,m1000 \leq n, m \leq 100, and 0km+n0 \leq k \leq m+n.


Notes

This problem is translated from COCI2010-2011 CONTEST #1 T1 TIMSKO.

Translated by ChatGPT 5