Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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
You can’t perform that action at this time.