Charlie丶one @ 2018-10-05 15:39:34
#include<iostream>
using namespace std;
void quicksort(int*yi,int start,int end)
{
if(start<end)
{
int key=yi[start];
int a=start;
int b=end-1;
bool direct=false;
while(a<b)
{
if(direct==false)
{
if(yi[b]<key)
{
yi[a]=yi[b];
direct=true;
a++;
}
else
b--;
}
else
{
if(yi[a]>=key)
{
yi[b]=yi[a];
direct=false;
b--;
}
else
a++;
}
}
yi[a]=key;
quicksort(yi,start,a);
quicksort(yi,a+1,end);
}
}
int main()
{
int n,s,c,d,sum=0;
int xi[5000],yi[5000];
cin>>n>>s>>c>>d;
int i;
for(int i=0;i<n;i++)cin>>xi[i]>>yi[i];
quicksort(yi,0,n);
for(i=0;i<n;i++){
if(c+d>xi[i]&&s>yi[i])
{
sum++;
s=s-yi[i];
}
}
cout<<sum;
return 0;
}
by 三点水一个各 @ 2018-10-05 15:41:53