#1,3,6,9WA 60分求调
查看原帖
#1,3,6,9WA 60分求调
1417265
limaotong楼主2025/6/22 12:28
#include<bits/stdc++.h>
using namespace std;
struct jq{
    int bh,sl;
}a[1001],b[1001];
bool cmp(jq a,jq b){
    if(a.sl<b.sl)return 1;
    return 0;
}
int main(){
	int t,n;
    cin>>t;
    for(int i=1;i<=t;i++){
        x:
        cin>>n;
        for(int j=1;j<=n;j++){
            cin>>a[j].sl;
            a[j].bh=j;
        }
        for(int j=1;j<=n;j++){
            cin>>b[j].sl;
            b[j].bh=j;
        }
        sort(a+1,a+n+1,cmp);
        sort(b+1,b+n+1,cmp);
        int sum=0,c[1001],d[1001],l=1;
        for(int j=n,k=1;j>0&&k<=n;j--,k++){
            a[j].sl+=sum;
            sum=0;
            if(a[j].sl<b[k].sl){
                cout<<"No\n";
                i++;
                goto x;
            }else{
                sum+=a[j].sl-b[k].sl;
                c[l]=a[j].bh;
                d[l++]=b[k].bh;
            }
        }
        cout<<"Yes\n";
        for(int j=1;j<=n;j++){
            cout<<c[j]<<' ';
        }
        cout<<'\n';
        for(int j=1;j<=n;j++){
            cout<<d[j]<<' ';
        }
        cout<<'\n';
    }
	return 0;
} 

试过把goto去掉,但去掉只剩30分了

2025/6/22 12:28
加载中...