|
- #include <algorithm>
- #include <iostream>
- #include <cmath>
- #include <cstring>
- #include <map>
- #include <string>
- #include <vector>
- #include <queue>
- #include <stack>
- #include <cstdio>
- #include <cstdlib>
- using namespace std;
- int n,w,t1,t,all=0;
- struct node
- {
- int h,q;
- }a[6000];
- bool cmp(node x,node y)
- {
- return x.q<y.q;
- }
- int main()
- {
- scanf("%d%d",&n,&w);
- scanf("%d%d",&t1,&t);t+=t1;
- for(int i=1;i<=n;i++)
- scanf("%d%d",&a[i].h,&a[i].q);
- sort(a+1,a+1+n,cmp);
- for(int i=1;i<=n;i++)
- {
- if(t>=a[i].h)
- {
- if(w-a[i].q>=0)
- w-=a[i].q,all++;
- else
- {
- printf("%d",all);
- return 0;
- }
- }
- }
- printf("%d",all);
- return 0;
- }
复制代码 |
|