标签:cstring mes www getchar pie using math std for
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
inline int read(){
int x=0,o=1;char ch=getchar();
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
if(ch=='-')o=-1,ch=getchar();
while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
return x*o;
}
const int N=105;
int a[N],sum[N],f[N];
int main(){
int n=read();
for(int i=1;i<=n;++i)a[i]=read();
for(int i=n;i>=1;--i)sum[i]=sum[i+1]+a[i];
for(int i=n;i>=1;--i){
f[i]=max(f[i+1],sum[i]-f[i+1]);
}
printf("%d %d\n",sum[1]-f[1],f[1]);
return 0;
}
标签:cstring mes www getchar pie using math std for
原文地址:https://www.cnblogs.com/PPXppx/p/11523526.html