Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <algorithm>
- #include <queue>
- using namespace std;
- ifstream fin("lupu.in");
- ofstream fout("lupu.out");
- struct oaie
- {
- long long dist, lana, timp;
- bool operator<(oaie rhs) const
- {
- return lana<rhs.lana;
- }
- } p[100002];
- bool comp_t(oaie s, oaie dr)
- {
- return s.timp>dr.timp;
- }
- priority_queue<oaie> q;
- long long N, X, L, ans, tmax;
- int main()
- {
- fin>>N>>X>>L;
- for (int i=1; i<=N; i++)
- {
- fin>>p[i].dist;
- fin>>p[i].lana;
- p[i].timp = (X-p[i].dist)/L;
- if (p[i].timp>tmax)
- tmax = p[i].timp;
- }
- sort(p+1,p+N+1, comp_t);
- long long pos = 1;
- for (long long d=tmax; d>=0; d--)
- {
- while (pos<=N && p[pos].timp==d)
- {
- q.push(p[pos]);
- pos++;
- }
- if (!q.empty())
- {
- ans+=q.top().lana;
- q.pop();
- }
- }
- fout<<ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement