diff --git a/P10464.cpp b/P10464.cpp new file mode 100644 index 0000000..41db9a3 --- /dev/null +++ b/P10464.cpp @@ -0,0 +1,34 @@ +// 127 +#include +using namespace std; +int n, m; +pair rob[100005], task[100005]; +int c[105]; +int main() +{ + scanf("%d%d", &n, &m); + for (int i = 1; i <= n; ++i) + scanf("%d%d", &rob[i].first, &rob[i].second); + for (int i = 1; i <= m; ++i) + scanf("%d%d", &task[i].first, &task[i].second); + sort(rob + 1, rob + n + 1, [](pair a, pair b) + { return (a.first == b.first) ? a.second > b.second : a.first > b.first; }); + sort(task + 1, task + m + 1, [](pair a, pair b) + { return (a.first == b.first) ? a.second > b.second : a.first > b.first; }); + int p = 0; + int cnt = 0; + long long ans = 0; + for (int i = 1; i <= m; ++i) + { + while (p < n && rob[p + 1].first >= task[i].first) + p++, c[rob[p].second]++; + for (int j = task[i].second; j <= 100; j++) + if (c[j]) + { + cnt++, c[j]--, ans += task[i].first * 500 + task[i].second * 2; + break; + } + } + printf("%d %lld\n", cnt, ans); + return 0; +} \ No newline at end of file