1. Be able to analyze the reasons for greed
2. Perform lower_bound in LV: because the time of the task is already sorted in ascending order, we should start from the smallest level for each time in the task,
Because there may be a relatively large LV behind the task;
3. lower_bound usage
4. Binary writing
5. Comparison function CMP
# Include <cstdio> # include <cstring> # include <iostream> # include <algorithm> # include <vector> # include <cmath> # include <queue> # include <stack> # include <map> # include <set> using namespace STD; # define CLR (x) memset (x, 0, sizeof (x) # define FP1 freopen ("in.txt", "r", stdin) # define fp2 freopen ("out.txt", "W", stdout) # define Pb push_back # define INF 0x3c3c3ctypedef _ int64 ll; const int maxn = 1e5 + 100; typedef struct NN {ll time, lv;} nn; nn task [maxn], Mac [maxn]; int n, m; Multiset <int> SS [150]; bool CMP (nn a, nn B) {if (. time> B. time) return true; else {if (. time = B. time) return. LV> B. LV; else return false;} int main () {// FP1; while (scanf ("% d", & N, & M) = 2) {for (INT I = 0; I <150; I ++) ss [I]. clear (); For (INT I = 1; I <= N; I ++) {scanf ("% i64d % i64d", & Mac [I]. time, & Mac [I]. LV); SS [Mac [I]. LV]. insert (MAC [I]. time) ;}for (INT I = 1; I <= m; I ++) {scanf ("% i64d % i64d", & task [I]. time, & task [I]. LV);} Sort (Task + 1, task + 1 + M, CMP); ll count = 0, sum = 0; For (INT I = 1; I <= m; I ++) {for (Int J = task [I]. LV; j <150; j ++) {If (ss [J]. size () = 0) continue; If (ss [J]. lower_bound (task [I]. time) = ss [J]. end () {continue;} else {count ++; Multiset <int >:: iterator it = ss [J]. lower_bound (task [I]. time); sum + = (task [I]. time * 500 + task [I]. LV * 2); SS [J]. erase (it); break ;}} printf ("% i64d % i64d \ n", Count, sum);} return 0 ;}