Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n,first = 0,st,f,a[101],moves,even,odd;
- bool odds;
- void getmove(bool c) {
- if (odds) {
- if (st % 2 == 1) {
- if (c)first += a[st];
- st++;
- }
- else {
- if (c)first += a[f];
- f--;
- }
- }
- else {
- if (st % 2 == 1) {
- if (c)first += a[f];
- f--;
- }
- else {
- if (c)first += a[st];
- st++;
- }
- }
- }
- int main() {
- cin>>n;
- for (int i = 1;i<=n;i++) {
- scanf("%d",&a[i]);
- if (i % 2 == 0)even += a[i];
- else odd += a[i];
- }
- if (odd >= even)odds = true;
- else odds = false;
- moves = n/2;
- st = 1;
- f = n;
- for (int i = 1;i<=moves;i++) {
- getmove(true);
- getmove(false);
- }
- cout<<first<<" "<<even+odd-first<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement