contest 1.18

D.装饰

列方程

#include <iostream>
#include<cstdio>
#include<algorithm>
typedef long long ll;
using namespace std;
 
ll a[5];
 
int main()
{
    int t;scanf("%d",&t);
    while(t--){
        scanf("%lld%lld%lld",&a[0],&a[1],&a[2]);
        sort(a,a+3);
        ll tmp=2*(a[0]+a[1])-a[2];
        if(tmp<=0){
            ll ans=a[0]+a[1];
            printf("%lld\n",ans);
        }
        else if(tmp%3==0){
            ll ans=tmp/3+(a[2]-tmp/3)/2;
            printf("%lld\n",ans);
        }
        else{
            ll ans1=tmp/3+(a[2]-tmp/3)/2;
            ll ans2=(tmp/3+1)+(a[0]+a[1]-2*(tmp/3+1));
            printf("%lld\n",max(ans1,ans2));
        }
    }
    return 0;
}
View Code

猜你喜欢

转载自www.cnblogs.com/lllxq/p/10286998.html