Cod sursa(job #3362695)

Utilizator Stefan_B_Ostefan bonchis Stefan_B_O Data 11 august 2026 13:52:13
Problema Lupul Urias si Rau Scor 16
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 2.26 kb
// #include <bits/stdc++.h>
// #define int long long
//
// using namespace std;
//
// ifstream fin("lupu.in");
// ofstream fout("lupu.out");
//
// int n, x, l;
// int blanaa=0;
// struct oaie {
//     int dist, blana;
//
//     bool operator<(const oaie &o) const {
//         if (dist != o.dist) {
//             return dist < o.dist;
//         }
//         else {
//             return blana < o.blana;
//         }
//     }
// };
//
// oaie v[100000];
// priority_queue<oaie> pq;
//
//
//
//
//
// signed main() {
//     fin>>n>>x>>l;
//     for (int i=0;i<n;++i) {
//         fin>>v[i].dist>>v[i].blana;
//         if (v[i].dist<=x) {
//             pq.push(v[i]);
//         }
//         //cout<< pq.top().blana<<endl;
//     }
//
//     // for (int i=0;i<n;++i) {
//     //     cout<<pq.top().dist<<" "<<pq.top().blana<<endl;
//     //     pq.pop();
//     // }
//     int ll=0 ;
//     while (pq.size()>0) {
//         int  b_m_loc=-1;
//         while (pq.size()>0 && pq.top().dist+ll+l>x) {
//             b_m_loc=max(b_m_loc,pq.top().blana);
//             // if (pq.size()==1) {
//             //     break;
//             // }
//             pq.pop();
//
//         }
//         blanaa+=b_m_loc;
//         // if () {
//         //     blanaa+=pq.top().blana;
//         //     //cout<<pq.top().blana<<" "<<pq.top().dist+ll<<endl;
//         ll+=l;
//         //
//         // }
//
//     }
//
//     fout<<blanaa;
//     return 0;
// }

#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lupu.in");
ofstream g("lupu.out");

int n, x, l;
struct lup{
    int d, b;}v[100005];


int main()
{
    int a, b, s=0, l0;
    fin>>n>>x>>l;
    l0=l;
    for(int i=1;i<=n;i++)
    {
        fin>>v[i].d>>v[i].b;
    }
    int k=1, i, j;
    while(k!=0)
    {
        k=0;
        int max=0;
        for(i=1;i<=n;i++)
        {
            if(v[i].d<=x)
                if(v[i].d+l>x && v[i].b>max)
                {
                    j=i;
                    max=v[i].b;
                }
        }
        s+=max;


        for(i=1;i<=n;i++)
            if(v[i].d+l>x)
            {
                v[i].b=-1;
                v[i].d=-1;
            }

        for(i=1;i<=n && k!=1;i++)
        {
            if(v[i].b!=-1) k=1;

        }
        l+=l0;
    }
    g<<s;
    return 0;
}