hiho一下 第175周 Robots Crossing River

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/MM_GS/article/details/78516067

题目链接


时间限制: 10000ms
单点时限: 1000ms
内存限制: 256MB

描述

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 XY and Z denoting the number of the three kinds of robots. (0 ≤ XY 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;
} 


猜你喜欢

转载自blog.csdn.net/MM_GS/article/details/78516067