forked from deepanshumishra/JavaAndCPP_programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDIV3.java
More file actions
45 lines (38 loc) · 875 Bytes
/
Copy pathDIV3.java
File metadata and controls
45 lines (38 loc) · 875 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
package codechef_lib;
import java.util.Scanner;
public class DIV3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i=1;i<=t;i++) {
int z = sc.nextInt();//number of zeros
int o = sc.nextInt();//number of ones
int w = sc.nextInt();//number of twos
int num = z;//number of sets possible_ min are zero's ones too
if (o>0 && w>0 && o>=w)
{
num+=w;
o-=w;
w=0;
}
if (o>0 && w>0 && w>=o)
{
num+=o;
w=w-o;
o=0;
}
if (w>0 && o==0)
{
num+=w/3;
w-=(w/3)*3;
}
if (o>0 && w==0)
{
num+=o/3;
o-=(o/3)*3;
}
System.out.println(num);
}
}
}