G-滑板比赛

  • 双指针
  • 牛牛的动作n>=m,所以要对牛妹的m个动作进行分析
  • 首先,对它们的华丽值进行从小到大排序,
  • 然后,从大到小去枚举m个动作
  • i表示牛妹第i个动作,j表示牛牛第j个动作
  • 若牛牛的华丽值小于或者等于牛妹的华丽值,这个动作不进行操作
  • 否则,进行比较,赢一次(ans ++),进行下一个动作的比较(j --)
#include<bits/stdc++.h>

using namespace std;

#define  mm(a,x) memset(a,x,sizeof a)
#define  mk make_pair
#define ll long long
#define pii pair<int,int>
#define inf 0x3f3f3f3f
#define lowbit(x) (x) & (-x)

const int N = 2e5 + 10;

int n,m;
int a[N],b[N];

int main() {
    cin >> n >> m;
    for(int i = 0; i < n; i ++ ) cin >> a[i];
    for(int i = 0; i < m; i ++ ) cin >> b[i];
    sort(a,a + n);sort(b,b + m);
    int ans = 0;
    for(int i = m - 1,j = n - 1; i >= 0; i -- ){
        if(a[j] <= b[i]) continue;
        else ans ++;j--;
    }
    cout<<ans;
    return 0; 
}