描述
Three kinds of robots want to move from Location A to Location B and then from Location B to Location C by boat.
The only one boat between A and B and only one between B and C. Moving from A to B (and vise versa) takes 2 hours with robots on the boat. Moving from B to C (and vice versa) takes 4 hours. Without robots on the boat the time can be reduced by half. The boat between A and B starts at time 0 moving from A to B. And the other boat starts 2 hours later moving from B to C.
You may assume that embarking and disembarking takes no time for robots.
There are some limits:
1. Each boat can take 20 robots at most.
2. On each boat if there are more than 15 robots, no single kind of robots can exceed 50% of the total amount of robots on that boat.
3. At most 35 robots are allowed to be stranded at B. If a robot goes on his journey to C as soon as he arrives at B he is not considered stranded at B.
Given the number of three kinds robots what is the minimum hours to take them from A to C?
输入
Three integers X, Y and Z denoting the number of the three kinds of robots. (0 ≤ X, Y and Z ≤ 1000)
输出
The minimum hours.
40 4 4样例输出
24
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int a[3];
int main()
{
cin>>a[0]>>a[1]>>a[2];
int ans=0;
sort(a,a+3);
int z=a[0],y=a[1],x=a[2];
if (x<=y+z){
ans=ceil((double)(x+y+z)/20);
}else{
double t=y+z;
while(t>=10){
t-=10;
x-=10;
ans++;
}
if (t>0){
x=x-max(t,15-t);
ans++;
}
ans+=ceil((double)x/15);
}
cout<<ans*6<<endl;
return 0;
}