-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path1250L.cpp
More file actions
64 lines (62 loc) · 671 Bytes
/
Copy path1250L.cpp
File metadata and controls
64 lines (62 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Author:Yashasvi
* Date: 28/10/19
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
int avg=a+b+c;
avg=avg/3;
bool r1,r2;
r1=r2=0;
if(avg-a>0)
{
r1=1;
if(b>(avg-a))
{
b-=(avg-a);
a=avg;
}
else{
a=a+b;
b=0;
}
}
if(avg-c>0)
{
r2=1;
if(b>(avg-c))
{
b-=(avg-c);
c=avg;
}
else{
c=c+b;
b=0;
}
}
//if(!r1&!r2)
if(a>c)
{
a=a+b;
b=0;
b=a/2;
a=a-b;
}
else{
c=c+b;
b=0;
b=c/2;
c=c-b;
}
// printf("%d %d %d\n",a,b,c);
printf("%d\n",max(max(a,b),c));
}
}