Codeforces Round #228 (Div. 1) C greedy
Ga ga, I was delayed by some things today, but I still have A few questions. This question is not bad.
Question link:
Two people play games, with N piles of cards and numbers on them. A can only take one of the top cards in N stacks at A time, B can only take one of the cards at the bottom of N heap. A and B want to maximize their sum and ask the last score.
After drawing, if the number of cards in a pile is an even number, it is found that two people are divided by half each, because if the other party wants to take the big card that belongs to his half from here, he will have time to block it,
Next there is an odd number. In fact, the odd number is the first card in the middle, and the other two is half of each card. Therefore, we should greedy each odd number of cards in the middle,
int n;typedef struct Node {int mid;int id;};Node node[100 + 55];int mp[100 + 55][100 + 55];int ss[100 + 55];void init() {memset(ss,0,sizeof(ss));memset(node,0,sizeof(node));}bool input() {while(cin>>n) {return false;}return true;}bool cmp(Node x,Node y) {return x.mid > y.mid;}void cal() {int ans1 = 0;int ans2 = 0;int cnt = 0;for(int i=0;i
0) {int k = node[i].id;for(int j=1;j<=(ss[k] + 1)/2;j++)ans1 += mp[k][j];for(int j=(ss[k] + 1)/2 + 1;j<=ss[k];j++)ans2 += mp[k][j];}else {int k = node[i].id;for(int j=1;j<=ss[k]/2;j++)ans1 += mp[k][j];for(int j=(ss[k] + 1)/2;j<=ss[k];j++)ans2 += mp[k][j];}mark *= -1;}cout<