mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-05-10 16:20:27 +08:00
43 lines
587 B
C++
43 lines
587 B
C++
#include <algorithm>
|
|
#include <iostream>
|
|
#include <iomanip>
|
|
#include <cstring>
|
|
#include <cstdio>
|
|
#include <ctime>
|
|
#include <cmath>
|
|
typedef long long l;
|
|
typedef double d;
|
|
typedef char c;
|
|
using namespace std;
|
|
struct wjh{
|
|
int x;
|
|
int y;
|
|
}arr[10000];
|
|
bool cmp(wjh a,wjh b){
|
|
return a.y<b.y;
|
|
}
|
|
int main(){
|
|
int a,b,c,d;
|
|
int cnt=0;
|
|
cin >>a>>b>>c>>d;
|
|
for(int i=0;i<a;i++){
|
|
cin >>arr[i].x>>arr[i].y;
|
|
}
|
|
sort(arr,arr+a,cmp);
|
|
for(int i=0;i<a;i++){
|
|
if(arr[i].x<=c+d){
|
|
b-=arr[i].y;
|
|
cnt++;
|
|
}
|
|
if(b<0){
|
|
cnt--;
|
|
break;
|
|
}
|
|
if(b==0){
|
|
break;
|
|
}
|
|
}
|
|
cout <<cnt;
|
|
return 0;
|
|
}
|