Pagini recente » Cod sursa (job #2941796) | Cod sursa (job #25140) | Cod sursa (job #1940689) | Cod sursa (job #3244088) | Cod sursa (job #3167938)
/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lupu.in");
ofstream fout("lupu.out");
int n,x,l,d[100005],a[100005],v[100005],s;
int main()
{
fin>>n>>x>>l;
for(int i=1;i<=n;i++)
{
fin>>d[i]>>a[i];
d[i]=(x-d[i])/l;
}
for(int i=1;i<=n;i++)
{
for(int j=i+1;j<=n;j++)
{
if(a[i]<a[j])
{
swap(a[i],a[j]);
swap(d[i],d[j]);
}
else if(a[i]==a[j])
{
if(d[i]>d[j])
{
swap(a[i],a[j]);
swap(d[i],d[j]);
}
}
}
}
for(int i=1;i<=n;i++)
{
if(v[d[i]]==0){v[d[i]]=a[i];}
else{
for(int j=d[i]-1;j>=0;j--)
{
if(v[j]==0){v[j]=a[i];break;}
}
}
}
for(int i=0;i<=x/l+1;i++)
{
s=s+v[i];
}
fout<<s;
fin.close();
fout.close();
return 0;
}