381A - Sereja Dina
28 Jan 2021 — Tags: None
Click to show code.
using namespace std;
using di = deque<int>;
using vi = vector<int>;
int main(void)
{
int n;
cin >> n;
di cards(n);
vi ans(2, 0);
for (auto &x : cards)
cin >> x;
for (int i = 0; i < n; ++i)
{
if (cards.front() < cards.back())
{
ans[i % 2] += cards.back();
cards.pop_back();
}
else
{
ans[i % 2] += cards.front();
cards.pop_front();
}
}
cout << ans[0] << " " << ans[1] << endl;
return 0;
}