fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5. int t;
  6. cin >> t;
  7. while(t--){
  8. int z, osoby = 0, osoby1 = 0, error = 0;
  9. cin >> z;
  10. while(z--){
  11. string czujnik;
  12. cin >> czujnik;
  13. if(czujnik == "AI") {
  14. osoby++;
  15. }
  16. else if(czujnik == "BI") {
  17. osoby1++;
  18. }
  19. else if(czujnik == "AO") {
  20. osoby1--;
  21. }
  22. else if(czujnik == "BO") {
  23. osoby--;
  24. }
  25. if(osoby < 0 || osoby1 < 0) {
  26. cout << "ERROR" << endl;
  27. error++;
  28. break;
  29. }
  30. }
  31. if(error == 0)
  32. cout << osoby + osoby1 << endl;
  33. }
  34. }
Time limit exceeded #stdin #stdout 5s 5568KB
stdin
Standard input is empty
stdout
0