AC代码:
#include<bits/stdc++.h>
using namespace std;
int n,k[2000001],m[2000001],l,r;
int main()
{
//freopen("medal.in","r",stdin);
//freopen("medal.out","w",stdout);
scanf("%d",&n);
l=n*0.2;
r=n*0.5;
for(int i=0;i<=n-1;i++)
{
scanf("%d",&k[i]);
m[i]=k[i];
}
sort(m,m+n-1);
for(int i=0;i<=n-1;i++)
{
if(k[i]>=m[n-l-1])
{
printf("0 ");
}
else if(k[i]>=m[n-r-1])
{
printf("1 ");
}
else if(k[i]>=0)
{
printf("2 ");
}
}
//fclose(stdin);
//fclose(stdout);
}