Special Chicken Distribution
InterviewTime limit1sMemory limit1024 MB
Given N pieces of each of three chicken kinds and soldier preference counts A, B, C, find the maximum number of soldiers who get their preferred chicken.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
For the Seollal holiday, the unit ordered chicken as a special meal for its soldiers. Fried chicken, soy sauce chicken, and seasoned chicken were each ordered in pieces, and the plan is to give one piece to each soldier.
To give as many soldiers as possible the kind of chicken they prefer, the soldier Eunu surveyed the soldiers' preferences. Among the three kinds, soldiers prefer fried chicken most, prefer soy sauce chicken most, and prefer seasoned chicken most. Every soldier chose only one kind when answering.
Find the maximum number of soldiers who can receive the kind of chicken they prefer most.
Input
The first line contains the number of pieces of each kind of chicken ordered.
The second line contains , the number of soldiers who prefer fried chicken most, , the number who prefer soy sauce chicken most, and , the number who prefer seasoned chicken most, separated by spaces.
Output
Print the maximum number of soldiers who can receive the kind of chicken they prefer most.