Skip to content

Instantly share code, notes, and snippets.

@ravikiran0606
Last active July 28, 2016 03:34
Show Gist options
  • Save ravikiran0606/1a628d3cb1c9bf339c5ad12a94d7808c to your computer and use it in GitHub Desktop.
Save ravikiran0606/1a628d3cb1c9bf339c5ad12a94d7808c to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
long long int a,b,c,ans1,ans2,ans;
while(t--)
{
cin>>a>>b>>c;
ans1=ans2=ans=0;
ans1=(a/3)+(b/3)+(c/3);
ans1+=(min(min(a%3,b%3),c%3));
if(a%3==0&&a!=0){
ans2+=((a-3)/3);
a=3;
}
else{
ans2+=(a/3);
a=a%3;
}
if(b%3==0&&b!=0){
ans2+=((b-3)/3);
b=3;
}
else{
ans2+=(b/3);
b=b%3;
}
if(c%3==0&&c!=0){
ans2+=((c-3)/3);
c=3;
}
else{
ans2+=(c/3);
c=c%3;
}
ans2+=(min(min(a,b),c));
ans=max(ans1,ans2);
cout<<ans<<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment