Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll int
- #define endl "\n"
- #define ld long double
- #define pb push_back
- #define all(n) n.begin(),n.end()
- #define eb emplace_back
- #define pll pair<ll,ll>
- #define YES cout <<"YES"<<endl;
- #define NO cout <<"NO"<<endl;
- #define ff first
- #define ss second
- #define setpre(x) fixed<<setprecision(x)
- #define heap priority_queue
- const ll maxn=2e5+100;
- const ll maxx=1e13;
- const ll mod=1000000007;
- const ll modGTG=1e6+9;
- const ll mod1=998244353;
- const ll base=27;
- priority_queue<pll,vector<pll>,greater<pll>> q;
- vector<ll> adj[maxn];
- vector<ll> adj1[maxn];
- ll dd[maxn];
- ll cnt[maxn];
- map<ll,multiset<ll,greater<ll>>> mp;
- multiset<ll> st;
- int main()
- {
- freopen("PENALTY.INP","r",stdin);
- freopen("PENALTY.OUT","w",stdout);
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- ll n,a,b;
- cin>>n>>a>>b;
- ll ans=0;
- for (int i=1;i<=n;i++)
- {
- ll x,y;
- cin>>x>>y;
- mp[x].insert(y);
- ans+=y;
- }
- ll pre=a;
- ll dunw=0;
- for (auto p:mp)
- {
- ll nw=p.ff;
- auto st1=p.ss;
- if (nw<=a) continue;
- if (nw<=b)
- {
- dunw=dunw+nw-pre;
- pre=nw;
- }
- else
- {
- dunw=dunw+b-pre;
- pre=b;
- }
- while (1)
- {
- // if (dunw<=0) break;
- if (st1.size()==0) break;
- auto it=st1.begin();
- auto k=*it;
- st.insert(k);
- st1.erase(it);
- dunw--;
- }
- while (dunw<0)
- {
- dunw++;
- st.erase(st.begin());
- }
- }
- //cout <<ans<<endl;
- while (!st.empty())
- {
- auto k=*st.begin();
- ans-=k;
- st.erase(st.begin());
- // cout <<k;
- }
- cout <<ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement