📄 2847046_ac_0ms_152k.cpp
字号:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int a[181];
int n;
int mark[181];
bool cmp(int t,int s)
{
return a[t] > a[s];
}
int main()
{
int i, inf, tmp;
int tmp1, tmp2;
int st, ed;
int c[181];
int ta, tb;
while(scanf("%d",&n)==1)
{
st = n;ed = 2*n;
inf = n*1000;
n *= 3;
for(i = 1; i <= n; i++)
scanf("%d",&a[i]),c[i] = i;
sort(&c[1],&c[1]+n,cmp);
tmp1 = tmp2 = 0;
for(i = 1; i <= st; i++)
tmp1 += a[c[i]];
for(i = st+1; i <= ed; i++)
tmp2 += a[c[i]];
while(tmp1*2<=inf||tmp2*2<=inf)
{
ta = (rand()%st+st)%st+1;
tb = (rand()%st+st)%st+st+1;
tmp1 -= a[c[ta]];tmp1 += a[c[tb]];
tmp2 -= a[c[tb]];tmp2 += a[c[ta]];
tmp = c[ta];
c[ta] = c[tb];
c[tb] = tmp;
}
for(i = 1; i <= n; i++)
printf("%d\n",c[i]);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -