Advertisement
Ritam_C

fun game hackerearth

Feb 12th, 2021
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define ld long double
  4. #define pb push_back
  5. #define p_b pop_back
  6. #define si stack<int>
  7. #define sll stack<ll>
  8. #define sc stack<char>
  9. #define vi vector<int>
  10. #define vll vector<ll>
  11. #define mii map<int, int>
  12. #define msi map<string, int>
  13. #define mci map<char, int>
  14. #define qc queue<char>
  15. #define qi queue<int>
  16. #define qll queue<ll>
  17. using namespace std;
  18.  
  19. int main(){
  20.     ios_base::sync_with_stdio(false);
  21.     cin.tie(NULL);
  22.     ll n;
  23.     qll a;
  24.     sll b;
  25.  
  26.     cin >> n;
  27.     for(ll i = 0; i < n; i++){
  28.         ll x;
  29.         cin >> x;
  30.         a.push(x);
  31.         b.push(x);
  32.     }
  33.  
  34.     while(a.size() > 0 && b.size() > 0){
  35.         if(a.front() > b.top()){
  36.             cout << 1 << " ";
  37.             b.pop();
  38.         } else if(a.front() < b.top()){
  39.             cout << 2 << " ";
  40.             a.pop();
  41.         } else{
  42.             cout << 0 << " ";
  43.             a.pop();
  44.             b.pop();
  45.         }
  46.     }
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement