15pts求hack
查看原帖
15pts求hack
1199534
ycy1124楼主2024/12/7 15:23
#include<bits/stdc++.h>
using namespace std;
struct Node{
    int w;
    bool bj;
}a[100005][2];
int b[100005][4];
int tot[4];
inline bool cmp(int x1,int x2){
    return x1>x2;
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<=1;i++){
        for(int j=1;j<=n;j++){
            cin>>a[j][i].w;
            if(a[j][i].w<0){
                a[j][i].bj=1;
                a[j][i].w=-a[j][i].w;
            }
        }
    }
    int ans=0;
    for(int i=0;i<=1;i++){
        for(int j=1;j<=n;j++){
            b[++tot[a[j][i].bj+i*2]][a[j][i].bj+i*2]=a[j][i].w;
        }
    }
    for(int i=0;i<=3;i++){
        sort(b[i]+1,b[i]+tot[i]+1,cmp);
    }//如果他是最矮的想和矮的
    int js[2];
    js[1]=1,js[0]=1;
    while(js[0]<=tot[0]&&js[1]<=tot[3]){
        // cout<<js[0]<<' '<<js[1]<<' '<<ans<<'\n';
        if(b[js[0]][0]<b[js[1]][3]){
            ++js[0];
            ++js[1];
            ans++;
        }
        else{
            js[0]++;
        }
    }
    js[0]=1,js[1]=1;
    while(js[0]<=tot[1]&&js[1]<=tot[2]){
        // cout<<b[js[1]][2].w<<' '<<b[js[0]][1].w<<' '<<ans<<'\n';
        if(b[js[0]][1]>b[js[1]][2]){
            ans++;
            ++js[0];
            ++js[1];
        }
        else{
            ++js[1];
        }
    }
    cout<<ans;
    return 0;
}
2024/12/7 15:23
加载中...