CodeForces 90A简单题
http://codeforces.com/problemset/problem/90/A
题意:登游览车,每过一辆要一分钟,有三种颜色的车,红,绿,蓝,给三个数,按次序他们是只上对应的车,比如:6 6 4,只上红车的是有6个人,绿车的6个,蓝车的4个,一个车只能做2人,上山要用30分钟,求最少要用多少时间。
关键:就是要求出最后一组(每三辆车为一组)是哪一辆车就行了。
关键在于考虑最大值相等的情况,比如6,6,4; #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int maxn(int a,int b,int c) { if(a>b)b=a; if(c>b)b=c; return b; } int main() { int r,g,b; while(scanf("%d%d%d",&r,&g,&b)!=EOF) { int sum=-1; int flag; if(r%2!=0)r++; if(g%2!=0)g++; if(b%2!=0)b++; int x=maxn(r,g,b); sum+=(x/2-1)*3; if(x==r)flag=1; if(x==g)flag=2; if(x==b)flag=3; printf("%d\n",sum+30+flag); } return 0; }

浙公网安备 33010602011771号