Cod sursa(job #3267324)

Utilizator Raul_AArdelean Raul Raul_A Data 11 ianuarie 2025 10:56:31
Problema Lupul Urias si Rau Scor 8
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.18 kb
#include <bits/stdc++.h>
#define ll long long
#define int ll
#define ld long double
#define pii pair<int, int>
#define tpl tuple<int, int, int>
#define piv pair<int, vector<int>>
#define eb emplace_back
#define oo INT_MAX / 2
#define OO LLONG_MAX / 2
using namespace std;

const string fn("lupu");

ifstream in(fn + ".in");
ofstream out(fn + ".out");

#define cin in
#define cout out

class cmp{
    public:
        bool operator()(pii a,pii b)
        {
            if(a.first<b.first)
                return 1;
            if(a.first==b.first and a.second<b.second)
                return 1;
            return 0;
        }
};

int N,X,L;
priority_queue<pii,vector<pii>,cmp> pq;

void solve()
{
    cin>>N>>X>>L;

    for(int i=1;i<=N;i++)
    {
        int d,a;
        cin>>d>>a;
        pq.emplace(a,d);
    }

    int timer=0,ans=0;

    while(!pq.empty())
    {
        int w,d;
        tie(w,d)=pq.top();
        pq.pop();

        if(d+L*timer<=X)
        {
            ans+=w;
            timer++;
        }
    }
    cout<<ans;
}

signed main()
{
    int q = 1;

    /// cin >> q;
    while (q--)
        solve();
    return 0;
}