Skip to content

Commit 09df749

Browse files
codeforces problemset
1221C *binary search *math
1 parent 89ab086 commit 09df749

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//Problem Link : https://codeforces.com/problemset/problem/1221/C
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
typedef long long ll;
6+
int main()
7+
{
8+
ll q;
9+
cin>>q;
10+
while(q--)
11+
{
12+
ll c,m,x,d;
13+
cin>>c>>m>>x;
14+
if(c<=x||m<=x||c==0||m==0)
15+
{
16+
cout<<min(c,m)<<endl;
17+
}
18+
else
19+
{
20+
c=c-x;m=m-x;
21+
if((c+m)/3>min(c,m))
22+
x=x+min(c,m);
23+
else
24+
x=x+(c+m)/3;
25+
cout<<x<<endl;
26+
}
27+
}
28+
return 0;
29+
}

0 commit comments

Comments
 (0)