Advertisement
Emiliatan

a271

Mar 14th, 2019
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. /* a271             */
  2. /* AC (0.1s, 368KB) */
  3. #include <iostream>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int t, x, y, z, w, n, m, toxic = 0, length;
  9. string in;
  10. inline int Eat(int radish)
  11. {
  12.     switch(radish)
  13.     {
  14.         case 0:
  15.             return 0;
  16.         case 1:
  17.             return x;
  18.         case 2:
  19.             return y;
  20.         case 3:
  21.             return -z;
  22.         case 4:
  23.             toxic+=n;
  24.             return -w;
  25.     }
  26. }
  27. int main()
  28. {
  29.     ios_base::sync_with_stdio(false); cin.tie(0);
  30.  
  31.     cin >> t;
  32.     for(int radish, i = 0; t-- ; i = 0, toxic = 0)
  33.     {
  34.         cin >> x >> y >> z >> w >> n >> m;
  35.         cin.ignore();
  36.         getline(cin, in, '\n');
  37.         length = in.length();
  38.  
  39.         while(i < length)
  40.         {
  41.             radish = in[i] - '0';
  42.             if(m <= 0) break;
  43.             m -= toxic;
  44.             if(m <= 0) break;
  45.             m += Eat(radish);
  46.             if(m <= 0) break;
  47.             i += 2;
  48.         }
  49.  
  50.         if(m <= 0) cout << "bye~Rabbit" << '\n';
  51.         else cout << m << 'g' << '\n';
  52.     }
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement