-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathproxy.java
More file actions
35 lines (34 loc) · 1003 Bytes
/
Copy pathproxy.java
File metadata and controls
35 lines (34 loc) · 1003 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
import java.util.Scanner;
/**
* proxy
*/
public class proxy {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int t=scan.nextInt();
for(int i=0;i<t;i++){
int l=scan.nextInt();
String s=scan.next();
int counta=0,countp=0;
for(int j=0;j<s.length();j++){
if(s.charAt(j)=='A'){
counta++;
}else{
countp++;
}
}
int r= (int) Math.ceil(0.75 * l);
//System.out.println(counta+" "+countp+" "+r);
int pro=0;
for(int k=2;k<s.length()-2;k++){
if((((s.charAt(k-2))=='P')||((s.charAt(k-1))=='P'))&&(((s.charAt(k+2))=='P')||((s.charAt(k+1))=='P'))){
pro= r-countp;
}else{
pro = -1;
}
}
System.out.println(pro);
}
scan.close();
}
}