Division into Teams CodeForces - 149C
原题链接
思路:
结论题,排序奇偶分组,均分,没想出怎么证明
Code
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 100010;
int n,sum,maxn;
bool vis[N];
struct Node{
int val,id;
bool operator<(const Node& r){
return this->val<r.val;
}
}node[N];
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&node[i].val);
node[i].id = i;
}//体积为n/2,价值v>=(sum-maxn)/2
sort(node+1,node+n+1);
printf("%d\n",n+1>>1);
for(int i=1;i<=n;i++)
if(i&1) printf("%d ",node[i].id);
printf("\n%d\n",n-(n+1)/2);
for(int i=1;i<=n;i++)
if(!(i&1)) printf("%d ",node[i].id);
return 0;
}