Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define io iostream::sync_with_stdio(false);
  3. #define ll long long int
  4.  
  5. using namespace std;
  6. int main()
  7. {
  8.     io;
  9.     list<int> lista;
  10.     int n;
  11.     cin >> n;
  12.     while(n--)
  13.     {
  14.         int x;
  15.         cin >> x;
  16.         lista.push_back(x);
  17.     }
  18.     int bob = 0, alice = 0, dif = 0;
  19.    
  20.     while(lista.size()>1)
  21.     {
  22.         if(lista.back()>lista.front()) //bob mais lento
  23.         {
  24.             alice ++;
  25.             int aux = lista.back();
  26.             lista.pop_back();
  27.             lista.push_back(aux-lista.front());
  28.             lista.pop_front();
  29.             cerr << "alice comeu e bob tah em " << lista.back() << endl;
  30.             cerr << "tamanho da lista " << lista.size() << endl;
  31.         }
  32.         else if(lista.front()>lista.back()) //alice mais lenta
  33.         {
  34.             bob ++;
  35.             int aux = lista.front();
  36.             lista.pop_front();
  37.             lista.push_front(aux-lista.back());
  38.             lista.pop_back();
  39.             cerr << "bob comeu e alice tah em " << lista.front() << endl;
  40.         }
  41.        
  42.         cerr << "alice = " << lista.front() << " | bob = " << lista.back() << endl;
  43.     }
  44.    
  45.    
  46.    
  47.     cout << alice << " " << bob << endl;
  48.    
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement