https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&itemid=8&page=show_problem& category=648&problem=5158&mosmsg=submission+received+with+id+1708713
/**uva LA 7146 2014 Shanghai Asian Race (greedy) topic: Given the number of soldiers and each soldier's attack and defensive power, if the two soldiers to fight, one side of the attack is greater than the other side of the defensive force, then successfully killed, may have to kill each other to ask where we can all kill the place Soldier's case, ask us how many of the remaining soldiers are the problem-solving ideas: This last year at the scene did not write out = = First of all to ensure that the local people are to be killed, then the attack of our soldiers descending order, the enemy soldiers in descending order of defense. Enumerate the enemy's soldiers, and multiset all our soldiers with more damage than their defensive forces, and then choose our soldiers with the first defensive force greater than the current enemy's attack, and if not, remove our soldiers with the lowest defensive force */#include <STR ing.h> #include <stdio.h> #include <algorithm> #include <iostream> #include <set>using Namespace Std;typedef long Long ll;const int maxn=100005;int m,n;struct note{int x, y; BOOL Operator < (const note &other) const {return x>other.x; }}a[maxn],b[maxn];int Main () {int t,tt=0; scanf ("%d", &t); while (t--) {scanf ("%d%d", &n,&m); for (int i=0;i<n;i++) {scanf ("%d%d", &a[i].x,&a[i].y); } for (int j=0;j<m;j++) {scanf ("%d%d", &b[j].y,&b[j].x); } sort (a,a+n); Sort (b,b+m); Multiset <inT> St; int p=0,ans=n; for (int i=0;i<m;i++) {while (b[i].x<=a[p].x&&p<n) {St.insert (A[P++].Y); } if (St.empty ()) {ans=-1; Break } multiset<int>::iterator It=st.upper_bound (B[I].Y); if (It==st.end ()) {St.erase (St.begin ()); ans--; } else St.erase (it); } printf ("Case #%d:%d\n", ++tt,ans); } return 0;} /**23 25 77 31 24 42 22 13 41 105 6*/
UVA LA 7146 2014 Shanghai Asian Race (greedy)