Title Link: Http://codeforces.com/problemset/problem/388/C
Test instructions: There are n decks on the table, each card has a weight, a person can take a card from the top of the pile, one can take a card from the bottom of the pile, taking turns until the card is not, all choose the best strategy, ask the last of their respective card weights and
Idea: Just started to think ... Each time to take the biggest card is not good, and then hit the face, according to game theory strategy because both sides have to suppress each other, each set of cards they each take half, if there is one last and all the rest of the sort to take turns
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #define MAXN 1030 u
Sing namespace std;
int S[MAXN];
int main () {int n,m;
while (scanf ("%d", &n)!=eof) {int res1=0,res2=0,cnt=0;
for (int j=0;j<n;j++) {//cout<< ":" <<j<<endl;
scanf ("%d", &m);
if (m%2==0) {for (int i=1;i<=m;i++) {int tem;
scanf ("%d", &tem);
if (I<=M/2) Res1+=tem;
else Res2+=tem; }} else {for (int i=1;i<=m;i++) {i
NT TEM;
scanf ("%d", &tem);
if (I<=M/2) Res1+=tem;
else if (i==m/2+1) S[cnt++]=tem;
else Res2+=tem;
}}} sort (s,s+cnt); int flag=1;
for (int i=cnt-1;i>=0;i--) {if (flag==1) res1+=s[i];
else Res2+=s[i];
Flag=!flag;
} printf ("%d%d\n", res1,res2);
}
}