Problem link: http://codeforces.com/problemset/problem/478/C
Logic:
Case 1:
If (number of maximum colored balloon)/2 is greater than or equal to sum of rest of the 2 colored balloons, then we can decorate each table with 2 balloons from maximum colored balloon and 1 balloon from either of the 2 other colored balloons.
Case 2:
If (number of maximum colored balloon)/2 is lesser than the sum of rest of the 2 colored balloons, then maximum number of tables that we can decorate would be (total number of balloons available)/3.
#include <vector> | |
#include <list> | |
#include <map> | |
#include <set> | |
#include <deque> | |
#include <queue> | |
#include <stack> | |
#include <bitset> | |
#include <algorithm> | |
#include <functional> | |
#include <numeric> | |
#include <utility> | |
#include <sstream> | |
#include <iostream> | |
#include <iomanip> | |
#include <cstdio> | |
#include <cmath> | |
#include <cstdlib> | |
#include <ctime> | |
#include <cstring> | |
#include <climits> | |
#include <stdlib.h> | |
#include <stdio.h> | |
using namespace std; | |
#define REP(i,n) for(int i=0; i<n; i++) | |
#define FOR(i,st,end) for(int i=st;i<end;i++) | |
#define db(x) cout << (#x) << " = " << x << endl; | |
#define mp make_pair | |
#define pb push_back | |
typedef long long int ll; | |
int main(){ | |
ll arr[3]; | |
REP(i,3){ | |
cin>>arr[i]; | |
} | |
sort(arr,arr+3); | |
if(arr[0]+arr[1]<=arr[2]/2){ | |
cout<<arr[0]+arr[1]; | |
} | |
else{ | |
cout<<((arr[0]+arr[1]+arr[2])/3); | |
} | |
} | |