Problem Statement
NN examinees took an entrance exam.
The examinee numbered ii scored A_iAi points in math and B_iBi points in English.
The admissions are determined as follows.
- XX examinees with the highest math scores are admitted.
- Then, among the examinees who are not admitted yet, YY examinees with the highest English scores are admitted.
- Then, among the examinees who are not admitted yet, ZZ examinees with the highest total scores in math and English are admitted.
- Those examinees who are not admitted yet are rejected.
Here, in each of the steps 1. to 3., ties are broken by examinees' numbers: an examinee with the smaller examinee's number is prioritized. See also Sample Input and Output.
Print the examinees' numbers of the admitted examinees determined by the steps above in ascending order, separated by newlines.
Constraints
- All values in input are integers.
- 1 \le N \le 10001≤N≤1000
- 0 \le X,Y,Z \le N0≤X,Y,Z≤N
- 1 \le X+Y+Z \le N1≤X+Y+Z≤N
- 0 \le A_i,B_i \le 1000≤Ai,Bi≤100
Input
Input is given from Standard Input in the following format:
NN XX YY ZZ A_1A1 A_2A2 \dots… A_NAN B_1B1 B_2B2 \dots… B_NBN
Output
Print the examinees' number of the admitted examinees in ascending order, separated by newlines.
Sample Input 1 Copy
6 1 0 2 80 60 80 60 70 70 40 20 50 90 90 80
Sample Output 1 Copy
1 4 5
结构体的使用
找出最大n个数字的
#include<stdio.h>
int main()
{
int n,x,y,z;
scanf("%d %d %d %d",&n,&x,&y,&z);
int a[1002],b[1002];
int i;
for(i=1;i<=n;i++){
scanf("%d",&a[i]);
}
for(i=1;i<=n;i++){
scanf("%d",&b[i]);
}
int j,dz[1002],k=0,max,dZ;
while(x--){//找出最大X个数字
//for(i=1;i<n;i++){
max=1;
for(j=2;j<=n;j++){
if(a[max]<a[j])
max=j;
//存储最大数字的下标号
}
dz[k++]=max;
a[max]=-1,b[max]=-1;//这个值去除掉
//}
}
while(y--){
//for(i=1;i<n;i++){
max=1;
for(j=2;j<=n;j++){
if(b[max]<b[j])
max=j;
}
dz[k++]=max;
a[max]=-1,b[max]=-1;
//}
}
while(z--){
//for(i=1;i<n;i++){
max=1;
for(j=2;j<=n;j++){
if(a[max]+b[max]<a[j]+b[j])
max=j;
}
dz[k++]=max;
a[max]=-1,b[max]=-1;
//}
}
for( i=0;i<k-1;i++){
for(j=0;j<k-i-1;j++){
if(dz[j]>dz[j+1]){
int t;
t=dz[j];
dz[j]=dz[j+1];
dz[j+1]=t;
}
}
}
for(i=0;i<k;i++)
printf("%d\n",dz[i]);
return 0;
}