求助

P3661 [USACO17FEB] Why Did the Cow Cross the Road I S

``` #include<bits/stdc++.h> using namespace std; struct cows{ int a,b; bool operator < (cows x) { return b<x.b; } } cow[20001]; multiset<int> chi; int n,m; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { int x; scanf("%d",&x); chi.insert(x); } for(int i=1;i<=m;i++) scanf("%d%d",&cow[i].a,&cow[i].b); sort(cow+1,cow+m+1); int ans=0; for(int i=1;i<=m;i++) { multiset<int>::iterator k=chi.lower_bound(cow[i].a); if(k!=chi.end()) { ++ans; chi.erase(k); } } cout<<ans; return 0; } ```
by 45dino @ 2020-03-24 12:20:32


|