-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
34 lines (27 loc) · 741 Bytes
/
Main.java
File metadata and controls
34 lines (27 loc) · 741 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
import java.util.Scanner;
public class Main {
public static void main(String[] args){
int[] C = new int[3];
int[] M = new int[3];
Scanner sc = new Scanner(System.in);
for(int i=0; i<3; i++){
C[i] = sc.nextInt();
M[i] = sc.nextInt();
}
for(int i=0; i<100; i++){
int curr = i % 3;
int next = (curr+1) % 3;
if(M[curr]+M[next] > C[next]){
M[curr] -= (C[next]-M[next]);
M[next] = C[next];
} else {
M[next] += M[curr];
M[curr] = 0;
}
}
for(int i : M){
System.out.println(i);
}
sc.close();
}
}