能暴力就暴力,对其中一个关键字排序,然后比较另外一个关键字

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;

#define Fast_IO ios::sync_with_stdio(false);
#define fn for(int i=1;i<=n;i++)
#define fm for(int j=1;j<=m;j++)
#define pr(a)  for(int i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n"
#define wh(n) while(n--)
#define sol(a) sort(a+1,a+n+1,less<int>())
#define sog(a) sort(a+1,a+n+1,greater<int>())
#define all(x) x.begin(),x.end()
#define endl '\n'

const ll maxn = 1e5 + 5;
struct node {
    int m,s;
    bool operator < ( const node& a ) {
        return m < a.m;
    }
}p[maxn];

int main()
{
    int n, sum = 0; cin >> n;
    fn cin >> p[i].m >> p[i].s;
    sort ( p + 1, p + n + 1 );
    for ( int i = 1; i <= n; i++ ) {
        for ( int j = i; j <= n; j++ ) {
            if ( p[i].s < p[j].s && i != j ) {
                sum++;
                break;
            }
        }
    }cout << sum << endl;
}