Advertisement
giabinh

P141PROA_DoiMat

Nov 25th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define fto(i, l, r) for (int i=l; i<=r; ++i)
  4.  
  5. using namespace std;
  6.  
  7. int start, n, a[10];
  8. bool found = false;
  9.  
  10. int main() {
  11.     #ifndef ONLINE_JUDGE
  12.         freopen("P141PROA.inp", "r", stdin);
  13.     #endif // ONLINE_JUDGE
  14.  
  15.     scanf("%d%d", &start, &n);
  16.     memset(a, 0, sizeof a);
  17.     while (n--)
  18.     {
  19.         int time; char ans;
  20.         scanf("%d %c", &time, &ans);
  21.         a[start] += time;
  22.  
  23.         if (a[start] > 210)
  24.         {
  25.             printf("%d\n", start);
  26.             found = true;
  27.             break;
  28.         }
  29.  
  30.         if (ans == 'T')
  31.         {
  32.             ++start;
  33.             if (start > 8)
  34.             {
  35.                 start = 1;
  36.                 a[1] = a[8];
  37.             }
  38.             else a[start] += a[start - 1];
  39.         }
  40.         //fto(i, 1, 8) cout << a[i] << " "; cout << endl;
  41.     }
  42.  
  43.     if (!found) printf("%d", start);
  44.  
  45.     //fto(i, 1, 8) cout << a[i] << " ";
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement