Serie A champions: a little.
Thinking: Greedy. Give the calculation formula, get the money very special title 500*x+2*y,y<=100, according to task time descending is possible,
Then each task to find out the multitasking and difficulty of the task has been completed nearest the machine.
#include <set> #include <cstdio> #include <iostream> #include <algorithm>using namespace std; typedef long LONG ll;const int N = 100005;struct Task {int x, y; BOOL operator< (const Task &RHS) Const {if (x = = rhs.x) return y > rhs.y; return x > rhs.x; }} Task[n];int Main () {int N, m; while (CIN >> n >> m) {multiset<int> s[105]; LL ans = 0; int maxlevel = 0, count = 0; for (int i = 0; i < n; i++) {int x, y; scanf ("%d%d", &x, &y); S[y].insert (x); Maxlevel = Max (Maxlevel, y); } for (int i = 0; i < m; i++) {scanf ("%d%d", &task[i].x, &TASK[I].Y); } sort (Task, task + M); for (int i = 0; i < m; i++) {int x = task[i].x; int y = task[i].y; for (int j = y; J <= Maxlevel; j + +) {if (S[j].empty ()) conTinue; Multiset<int>::iterator iter = S[j].lower_bound (x); if (iter = = S[j].end () | | *iter < x) {continue; } else {count++; Ans + = 500LL * x + 2ll * y; S[j].erase (ITER); Break }}} cout << count << "<< ans << endl; } return 0;}
Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.
HDU 4864 (Task)