-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCostCutting.java
More file actions
48 lines (44 loc) · 1.1 KB
/
CostCutting.java
File metadata and controls
48 lines (44 loc) · 1.1 KB
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
package com.supereasy;
import java.util.*;
import java.io.*;
//11727
public class CostCutting {
public static void main(String[] args) throws Exception{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
int t = Integer.parseInt(reader.readLine()), data[], temp, c = 1;
while(t-- != 0) {
data = Arrays.asList(reader.readLine().trim().split(" ")).stream().mapToInt(s -> Integer.parseInt(s)).toArray();
if(data[0] > data[2]) {
temp = data[0];
data[0] = data[2];
data[2] = temp;
}
if(data[1] > data[2]) {
temp = data[1];
data[1] = data[2];
data[2] = temp;
}
if(data[0] > data[1]) {
temp = data[0];
data[0] = data[1];
data[1] = temp;
}
writer.write(String.format("Case %d: %d\n", c, data[1]));
c++;
}
writer.close();
}
static void sort(int[] a) {
int tmp;
for(int i = 0; i < a.length; i++) {
for(int j = 1; j < a.length - i; j++) {
if(a[j] < a[j-1]) {
tmp = a[j];
a[j] = a[j-1];
a[j-1] = tmp;
}
}
}
}
}