plutolove’s diary

I love three things in this world, the sun, the moon and you. The sun for the day, the moon for the night, and you forever。

Codeforces Round #273 Div. 2 C. Table Decorations

題目鏈接:http://codeforces.com/contest/478/problem/C

題意

有綠色氣球a個,紅色b個,藍色c個 三個一組,每組的三個氣球顏色不能完全一樣,輸出最多分多少組

解法

假設abc,按升序排列

  • 如果(a+b)*2<c,答案就等於a+b
  • 如果(a+b)*2>=c答案就等於(a+b+c)/3
#include<bits/stdc++.h>
using namespace std;
int main() {
     #ifndef ONLINE_JUDGE
     freopen("in.txt","r",stdin);
     #endif
     long long a[3];
     while(cin>>a[0]>>a[1]>>a[2]) {
         sort(a,a+3);
         if((a[0]+a[1])*2<a[2]) cout<<a[1]+a[0]<<endl;
         else {
             cout<<(a[0]+a[1]+a[2])/3<<endl;
         }
     }
     return 0;
}