题目链接:Codeforces 381A Sereja and Dima
题目大意:给出一串数字,两个人玩游戏,可以从头和从尾取数字,每个人都尽量取的数字总和大。
解题思路:水题,直接模拟,每次取走头或尾中较大的值。
#include <stdio.h>
#include <string.h>
const int N = 1005;
int n, num[N];
void init () {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &num[i]);
}
void solve () {
int x = 0, y = 0, p = 0, q = n-1;
int cnt = 0;
while (p <= q) {
if (cnt & 1) {
if (num[p] > num[q]) {
y += num[p