Cod sursa(job #911678)

Utilizator valentina506Moraru Valentina valentina506 Data 11 martie 2013 20:20:02
Problema Lupul Urias si Rau Scor 16
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include<fstream>
#include<set>
#include<algorithm>
using namespace std;
int n,m,k,i;
struct oaie
{
    unsigned long long dist,l;
};
oaie a[100001];
unsigned long long max1[1000001],sol,pas;
bool cmp(oaie &a, oaie &b)
{
    return a.l>b.l;
}
int main()
{
    ifstream f("lupu.in");
    ofstream g("lupu.out");
    f>>n>>m>>k;
    for(i=1;i<=n;++i)
    {
        f>>a[i].dist>>a[i].l;
        if(a[i].dist<=m)
        {a[i].dist=(m-a[i].dist)/k+1;
        pas=max(pas,a[i].dist);
        max1[a[i].dist]=max(max1[a[i].dist],a[i].l);}
    }
    for(i=1;i<=pas;++i)
    sol+=max1[i];
    g<<sol;
}