You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# include <bits/stdc++.h>
using namespace std ;
typedef long long LL ;
const int N = 5010 ;
int n , s ; //苹果数 n, 力气 s
int a , B ; //椅子的高度a, 陶陶手伸直的最大长度b。
struct apple {
int x , y ;
} apples [ N ] ;
bool cmp ( const apple & a , const apple & b ) {
return a . y < b . y ;
}
int cnt ; //结果数
//每行两个数 苹果高度 xi,摘这个苹果需要的力气yi
int main ( ) {
cin > > n > > s > > a > > b ;
for ( int i = 1 ; i < = n ; i + + ) cin > > apples [ i ] . x > > apples [ i ] . y ;
//排序
sort ( apples + 1 , apples + 1 + n , cmp ) ;
for ( int i = 1 ; i < = n ; i + + )
if ( a + b > = apples [ i ] . x & & s > = apples [ i ] . y ) { //能够的到,而且力气够用
cnt + + ;
s - = apples [ i ] . y ;
}
//输出大吉
cout < < cnt < < endl ;
return 0 ;
}