-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP390.java
71 lines (62 loc) · 1.82 KB
/
P390.java
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
65
66
67
68
69
70
71
package buclesSimples;
import java.util.Scanner;
//accepted
public class P390 {
public static void main(String[] args) {
Scanner scN = new Scanner(System.in);
int m, a, c, posicion;
String colors;
char tono;
int casos = scN.nextInt();
for (int i = 0 ; i<casos; i++){
boolean disponible= true;
m = scN.nextInt();
a = scN.nextInt();
c = scN.nextInt();
colors = scN.next();
posicion = colors.length()-1;
for (int j = 0; j<colors.length(); j++){
tono = colors.charAt(posicion);
switch (tono){
case 'M':
m--;
break;
case 'A':
a--;
break;
case 'C':
c--;
break;
case 'R':
m--;
a--;
break;
case 'V':
a--;
c--;
break;
case 'L':
m--;
c--;
break;
case 'N':
m--;
c--;
a--;
break;
case 'B':
break;
}
if (m<0 || c<0 || a<0){
disponible = false;
break;
}else {posicion--;}
}
if (disponible){
System.out.println("SI "+ m + " " + a + " " +c);
}else {
System.out.println("NO");
}
}
}
}