2500*2500直接排序暴力贪心
#include<iostream>#include<cstring>#include<algorithm>using namespace std;#define maxn 3000struct ac{ int x,y;}a[maxn],b[maxn];bool cmp(ac q,ac w){ return q.x>w.x;}int main(){ int n,m; cin>>n>>m; ;j<=n;j++){ cin>>a[j].x>>a[j].y; } ;k<=m;k++){ cin>>b[k].x>>b[k].y; } sort(a+,a++n,cmp); sort(b+,b++m,cmp); ; ;j<=n;j++){ ;k<=m;k++){ if(a[j].x>b[k].x) break; ){ ans++; b[k].y--; break; } } } cout<<ans<<endl;}