-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeadPixel.java
More file actions
73 lines (72 loc) · 1.55 KB
/
DeadPixel.java
File metadata and controls
73 lines (72 loc) · 1.55 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import java.io.*;
import java.util.*;
public class DeadPixel {
public static void main(String[] args) throws NumberFormatException, IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
/*int N = Integer.parseInt(br.readLine());
int a, b, x, y;
String[] temp;
int area;
for (int i = 0; i < N; i++)
{
temp = br.readLine().split(" ");
a = Integer.parseInt(temp[0]);
b = Integer.parseInt(temp[1]);
x = Integer.parseInt(temp[2]);
y = Integer.parseInt(temp[3]);
area = Math.max(Math.max(x*b, (a-x-1)*b), Math.max(y*a, (b-y-1)*a));
System.out.println(area);
}*/
int N = Integer.parseInt(br.readLine());
String[] temp;
int a, b, money, i;
char[] seq;
char current;
int currInd, total;
for (int j = 0; j < N; j++)
{
temp = br.readLine().split(" ");
a = Integer.parseInt(temp[0]);
b = Integer.parseInt(temp[1]);
money = Integer.parseInt(temp[2]);
seq = br.readLine().toCharArray();
i = seq.length-2;
current = seq[seq.length-2];
currInd = seq.length-1;
total = 0;
while (i > -1)
{
if (seq[i] != current)
{
if (current == 'A')
total += a;
else
total += b;
if (total > money)
{
System.out.println(currInd+1);
break;
}
current = seq[i];
currInd = i + 1;
}
if (i == 0)
{
if (current == 'A')
total += a;
else
total += b;
if (total > money)
{
System.out.println(currInd+1);
break;
}
else
System.out.println("1");
}
i--;
}
}
}
}