diff --git a/26.cpp b/26.cpp new file mode 100644 index 0000000..f3df234 --- /dev/null +++ b/26.cpp @@ -0,0 +1,33 @@ +// 110 +#include +using namespace std; +int n, m; +pair s[2505]; +pair spf[2505]; +int main() +{ + scanf("%d%d", &n, &m); + for (int i = 1; i <= n; ++i) + scanf("%d%d", &s[i].first, &s[i].second); // min max + sort(s + 1, s + n + 1, [](pair x, pair y) + { return x.second > y.second; }); // 按 max 降序 + for (int i = 1; i <= m; ++i) + scanf("%d%d", &spf[i].first, &spf[i].second); + sort(spf + 1, spf + m + 1, [](pair x, pair y) + { return x.first > y.first; }); // 按 spf 降序 + + int point = 1; + priority_queue> q; // 按 min 降序 + int ans = 0; + for (int i = 1; i <= m; ++i) + { + while (point <= n && s[point].second >= spf[i].first) + q.push(s[point++]); + while (!q.empty() && q.top().first > spf[i].first) + q.pop(); + while (!q.empty() && spf[i].second > 0) + q.pop(), spf[i].second--, ans++; + } + printf("%d\n", ans); + return 0; +} \ No newline at end of file diff --git a/README.md b/README.md index 71603c9..c045a6c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # acwing -[题单](https://www.acwing.com/activity/content/introduction/6/) \ No newline at end of file +- [acwing](https://www.acwing.com/activity/content/introduction/6/) +- [luogu](https://www.luogu.com.cn/training/505362)