Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- #include <ctime>
- #include <cstring>
- #include <string>
- #include <queue>
- #include <set>
- #include <map>
- #include <vector>
- #include <algorithm>
- #include <cmath>
- using namespace std;
- typedef unsigned long long ull;
- const int MAXN=111111;
- int n,i,j,x,t;
- pair<int,int> a[MAXN];
- set<int> f;
- int main()
- {
- freopen("jumps.in","r",stdin);
- freopen("jumps.out","w",stdout);
- cin >> n;
- for (i=0;i<n;i++) {
- cin >> x >> t;
- a[i]=make_pair(x,t);
- }
- sort(a,a+n);
- reverse(a,a+n);
- for (i=1;i<=n;i++)
- f.insert(i);
- long long ans=0;
- for (i=0;i<n;i++) {
- int pos=a[i].second+1;
- set<int>::iterator it = f.lower_bound(pos);
- if (it==f.end()) {
- ans+=(long long)a[i].first;
- }
- else {
- f.erase(it);
- }
- }
- cout << ans << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement