10分,求助
查看原帖
10分,求助
1203149
lwjcyerlzp54188楼主2025/7/23 09:51
#include<bits/stdc++.h>
using namespace std;
struct c{
	int x;
	double h;
}cl[10010];
bool mar(c s,c r){
	if(s.h>r.h){
		return s.h<r.h;
	}
	else{
		return s.h>r.h;
	}
}
int main(){
	int T;
	cin>>T;
	while(T--){
		int stu;
		cin>>stu;
		for(int i=0;i<stu;i++){
			cin>>cl[i].x;
		}
		for(int i=0;i<stu;i++){
			cin>>cl[i].h;
		}
		sort(cl,cl+stu,mar);
		for(int i=0;i<stu;i++){
			if(cl[i].x==0){
				cout<<cl[i].h<<" ";
			}
		}
		cout<<endl;
		for(int i=0;i<stu;i++){
			if(cl[i].x==1){
				cout<<cl[i].h<<" ";
			}
		}
        cout<<endl;
	}
	return 0; 
}
2025/7/23 09:51
加载中...