fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main ()
  5. {
  6. int Next[9]={0, 2, 3, 4, 5, 6, 7, 8, 1};
  7. int tmleft=210;
  8. int K;
  9. cin>>K;
  10. int N;
  11. cin>>N;
  12. int loser;
  13. int t;
  14. char TNP;
  15. int finded=0;
  16. for (int i=1; i<=N; i++)
  17. {
  18. cin>>t>>TNP;
  19. if (finded==0)
  20. {
  21. if (tmleft>t)
  22. {
  23. tmleft=tmleft-t;
  24. loser=K;
  25. if (TNP=='T') K=Next[K];
  26. }
  27. else
  28. {
  29. loser=K;
  30. finded=1;
  31. }
  32. }
  33. }
  34. cout<<loser;
  35. return 0;
  36. }
Success #stdin #stdout 0s 15240KB
stdin
5
6
70 T
50 P
30 N
50 T
30 P
80 T
stdout
7