1287A Angry Student

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. int tc,n,cnt,tmp_cnt;
  5. cin >> tc;
  6. while(tc--) {
  7. cnt = tmp_cnt = 0;
  8. cin >> n;
  9. char stu_row[n];
  10. cin >> stu_row;
  11. for(int i = 0; i<strlen(stu_row); i++) {
  12. if(stu_row[i] == 'A') {
  13. for(int j = i+1; j<=strlen(stu_row); j++) {
  14. if(stu_row[j] == 'P')
  15. ++tmp_cnt;
  16. else if(stu_row[j] == 'A') {
  17. break;
  18. }
  19. }
  20. if(tmp_cnt > cnt) {
  21. cnt = tmp_cnt;
  22. }
  23. tmp_cnt = 0;
  24. }
  25. }
  26. cout << cnt << endl;
  27. }
  28. }

Comments

Popular posts from this blog

Codeforce Problem 1703A. YES or YES?

1535A. Fair Playoff

Aptitude test assistant programmer 2018