Cod sursa(job #1050802)

Utilizator rebound212Mihnea Savu rebound212 Data 9 decembrie 2013 10:08:20
Problema Lupul Urias si Rau Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.91 kb
#include <cstdio>
#include <set>
#include <vector>
#include <algorithm>
#define s second
#define f first
using namespace std;
multiset <int> h;
struct oi{int t,g};
oi a[100];

pair <int,int> o;
multiset <int>::iterator it;

using namespace std;
int x,i,sol,l,j,poz,lan,n,timp,t;
int main()
{
    freopen("lupu.in","r",stdin);
    freopen("lupu.out","w",stdout);
    scanf("%d %d %d",&n,&x,&l);
    for(i=1; i<=n; i++)
    {
        scanf("%d %d",&poz,&a[i].l);
        if(poz<=x)
        {
            timp=(x-poz)/l+1;
            a[i].t=timp;
        }
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
   o=*(a.begin());
   j=o.f;
i=1;
    for(t=j; t>=1; t--)
    {
        while(a[i].f==t)

            {h.insert(a[i].s);
            i++;

            }


       it=h.end();
        it--;
        sol+=*it;
        h.erase(it);
        }


    return 0;
}