Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n,t,l,e;
- cin >> n >> t;
- multimap<int, int> monster;
- for (int i = 0; i < n; ++i)
- {
- cin >> l >> e;
- monster.insert(pair<int, int>(l,e));
- }
- int now = 0, res = 0;
- priority_queue<int, vector<int>, greater<int> > pq;
- for (auto i = monster.begin(); i != monster.end();)
- {
- if ((i -> first)/t == now)
- {
- if (pq.size() < now + 1)
- pq.push(i -> second);
- else if (i -> second > pq.top())
- {
- pq.pop();
- pq.push(i -> second);
- }
- i++;
- }
- else
- {
- now = (i -> first)/t;
- }
- }
- while (!pq.empty())
- {
- res += pq.top();
- pq.pop();
- }
- cout << res << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement