T3000

Untitled

Apr 13th, 2022 (edited)
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 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.         ll p1 = 0, p2 = 0;
  12.         vector<pair<string, ll>> z1(n);
  13.         for (int i = 0; i < n; i++)
  14.         {
  15.             cin >> z1.at(i).first;
  16.             cin >> z1.at(i).second;
  17.         }
  18.         for (int i = 0; i < n; i++)
  19.         {
  20.             if (z1.at(i).first != "DROP" && p1 == 0 && p2 != 0)
  21.             {
  22.  
  23.                 cout << "MOVE 2->1 " << p2 << endl;
  24.                 p1 += p2;
  25.                 p2 = 0;
  26.             }
  27.  
  28.             if (z1.at(i).first == "DROP")
  29.             {
  30.  
  31.                 cout << "DROP 2 " << z1.at(i).second << endl;
  32.  
  33.                 p2 += z1.at(i).second;
  34.             }
  35.             else
  36.             {
  37.                 cout << "TAKE 1 " << z1.at(i).second << endl;
  38.                 p1 -= z1.at(i).second;
  39.             }
  40.         }
  41.         cout << '\n';
  42.     }
  43.     return 0;
  44. }
Add Comment
Please, Sign In to add comment