Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define io iostream::sync_with_stdio(false);
- #define ll long long int
- using namespace std;
- int main()
- {
- io;
- list<int> lista;
- int n;
- cin >> n;
- while(n--)
- {
- int x;
- cin >> x;
- lista.push_back(x);
- }
- int bob = 0, alice = 0, dif = 0;
- while(lista.size()>1)
- {
- if(lista.back()>lista.front()) //bob mais lento
- {
- alice ++;
- int aux = lista.back();
- lista.pop_back();
- lista.push_back(aux-lista.front());
- lista.pop_front();
- cerr << "alice comeu e bob tah em " << lista.back() << endl;
- cerr << "tamanho da lista " << lista.size() << endl;
- }
- else if(lista.front()>lista.back()) //alice mais lenta
- {
- bob ++;
- int aux = lista.front();
- lista.pop_front();
- lista.push_front(aux-lista.back());
- lista.pop_back();
- cerr << "bob comeu e alice tah em " << lista.front() << endl;
- }
- cerr << "alice = " << lista.front() << " | bob = " << lista.back() << endl;
- }
- cout << alice << " " << bob << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement