原题链接
考察:思维
过了这题的有1w+,本蒟蒻直接去死算了()
思路:
??假设排序后\(a[0],a[1],a[2]\)
??分两种情况:
??此时的最优解是(a[1]+a[2]+a[0])/3
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N =3;
LL a[N];
int main()
{
for(int i=0;i<3;i++) scanf("%lld",&a[i]);
sort(a,a+3);
LL res = 0;
if(a[2]>=2*(a[1]+a[0])) res = a[1]+a[0];
else{
int t = (a[2]-a[1]+1)/2;
res+=t;
a[2]-=t*2,a[1]-=t;
res +=(a[1]+a[0]+a[2])/3;
}
printf("%lld\n",res);
return 0;
}
Table Decorations CodeForces - 478C
原文:https://www.cnblogs.com/newblg/p/14956838.html