Pagini recente » Cod sursa (job #238708) | Cod sursa (job #2608136) | Cod sursa (job #1333789) | Cod sursa (job #1764875) | Cod sursa (job #849439)
Cod sursa(job #849439)
#include<stdio.h>
#include<algorithm>
using namespace std ;
struct brailu
{
long long y ;
long x , pozi , nr ;
} a [ 37 ] ;
inline bool cmp1 ( brailu b , brailu c )
{
return b . y > c . y ;
}
inline bool cmp2 ( brailu b , brailu c )
{
return b . pozi > c . pozi ;
}
long nr [ 37 ] , nrt , nr2 ;
long long sum , n , c ;
int main ( )
{
freopen ( "shop.in" , "r" , stdin ) ;
freopen ( "shop.out" , "w" , stdout ) ;
scanf ( "%lld %lld %lld" , & n , & c , & sum ) ;
for ( long i = 1 ; i <= n ; ++ i )
{
a [ i ] . y = 1 ;
a [ i ] . pozi = i ;
scanf ( "%ld %ld" , & nr2 , & a [ i ] . x ) ;
for ( long j = 1 ; j <= nr2 ; ++ j )
a [ i ] . y *= c ;
}
sort ( a + 1 , a + n + 1 , cmp1 ) ;
for ( long i = 1 ; i <= n ; ++ i )
while ( sum >= a [ i ] . y && a [ i ] . x != 0 && sum != 0 )
sum -= a [ i ] . y , -- a [ i ] . x , ++ a [ i ] . nr , ++ nrt ;
sort ( a + 1 , a + n + 1 , cmp2 ) ;
printf ( "%ld\n" , nrt ) ;
for ( long i = n ; i >= 1 ; -- i )
printf ( "%ld " , a [ i ] . nr ) ;
return 0 ;
}