Pagini recente » Cod sursa (job #1114586) | Cod sursa (job #116760) | Cod sursa (job #2532467) | Cod sursa (job #238722) | Cod sursa (job #829800)
Cod sursa(job #829800)
# include <algorithm>
# include <cstdio>
# include <queue>
using namespace std ;
# define T first
# define D second.first
# define A second.second
const char *FIN = "lupu.in", *FOU = "lupu.out" ;
const int MAX = 100005, hg = 1 << 13 ;
pair < int, pair < int, int > > V[MAX] ;
priority_queue < int > H ;
int N, X, L, maxi, poz ;
char ch[ hg ] ;
inline void cit ( int &x ) {
if ( ch[0] == '\0' ) fread ( ch, 1, hg, stdin ) ;
else
while (ch[poz] < '0' || ch[poz] > '9')
if (++poz == hg) fread (ch, 1, hg, stdin), poz = 0;
x = 0;
while (ch[poz] >= '0' && ch[poz] <= '9') {
x = x * 10 + ch[poz] - '0';
if (++poz == hg) fread (ch, 1, hg, stdin), poz = 0;
}
}
void read_data ( void ) {
freopen ( FIN, "r", stdin ) ;
cit ( N ) , cit ( X ) , cit ( L ) ;
for ( int i = 1; i <= N; ++i ) {
cit ( V[i].D ) , cit ( V[i].A ) ;
V[i].T = ( X - V[i].D ) / L ;
maxi = max ( maxi, V[i].T ) ;
}
sort ( V + 1, V + N + 1, greater < pair < int, pair < int, int > > > () ) ;
}
void solve ( void ) {
long long rez = 0 ;
for ( int i = 1; maxi >= 0; --maxi ) {
for ( ; maxi == V[i].T ; H.push ( V[i++].A ) ) ;
if ( ! H.empty () ) {
rez += H.top () ;
H.pop () ;
}
}
fprintf ( fopen ( FOU, "w" ) , "%lld", rez ) ;
}
int main ( void ) {
read_data (), solve () ;
}