1 solutions

  • 0
    @ 2025-12-3 16:59:04

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    const int maxn=200005;
    int G,n,ans,x[maxn],y[maxn],X[maxn],Y[maxn];
    int main()
    {
    //	freopen("a.in","r",stdin);
    //	freopen("a.out","w",stdout);
    		scanf("%d",&n);
    		for (int i=1;i<=n;i++)
    		{
    			scanf("%d%d",&x[i],&y[i]);
    			X[i]=x[i];
    			Y[i]=y[i];
    		}
    		sort(X+1,X+1+n);
    		sort(Y+1,Y+1+n);
    		ans=n-1;
    		for (int i=1,A,B;i<=n;i++)
    		{
    			A=lower_bound(Y+1,Y+1+n,x[i])-Y-1;
    			B=n-(upper_bound(X+1,X+1+n,y[i])-X)+1;
    			ans=min(ans,A+B);
    		}
    		printf("%d\n",ans);
    	return 0;
    }
    
    • 1

    Information

    ID
    941
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    (None)
    Tags
    (None)
    # Submissions
    0
    Accepted
    0
    Uploaded By