B - Better Students Are Needed!

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.

  1. XX examinees with the highest math scores are admitted.
  2. Then, among the examinees who are not admitted yet, YY examinees with the highest English scores are admitted.
  3. Then, among the examinees who are not admitted yet, ZZ examinees with the highest total scores in math and English are admitted.
  4. 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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值