T3000

Untitled

Apr 13th, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using ll = long long;
  5.  
  6. int main()
  7. {
  8.     ll n;
  9.     while (cin >> n && n != 0)
  10.     {
  11.         string a;
  12.         ll w;
  13.         ll p1 = 0, p2 = 0;
  14.         for (int i = 0; i < n; i++)
  15.         {
  16.             cin >> a >> w;
  17.             if (a.at(0) == 'D')
  18.             {
  19.                 cout << "DROP 2 " << w << endl;
  20.  
  21.                 p2 += w;
  22.             }
  23.             else
  24.             {
  25.                 if (w != 0 && p1 == 0 && p2 != 0)
  26.                 {
  27.                     cout << "MOVE 2->1 " << p2 << endl;
  28.                     p1 += p2;
  29.                     p2 = 0;
  30.                 }
  31.                 cout << "TAKE 1 " << w << endl;
  32.                 p1 -= w;
  33.             }
  34.         }
  35.         cout << '\n';
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment