BookofDeath @ 2019-03-03 22:29:42
#include<iostream>
#include<algorithm>
using namespace std;
int n,s,a,b,x[10010],y[10010],ans,sum;
int main()
{
cin>>n>>s>>a>>b;
for(int i=1;i<=n;i++)
cin>>x[i]>>y[i];
int t=a+b;
for(int i=1;i<=n;i++)
{
if(x[i]>t)
y[i]=s+1;
}
sort(y+1,y+n+1);
for(int i=1;i<=n;i++)
{
int m;
m=s;
if(m>=y[i])
{
ans++;
m-=y[i];
}
}
cout<<ans<<endl;
return 0;
}
by 时间重洗 @ 2019-03-03 22:35:23
@BookofDeath
#include<iostream>
#include<algorithm>
using namespace std;
int n,s,a,b,x[10010],y[10010],ans,sum;
int main()
{
cin>>n>>s>>a>>b;
for(int i=1;i<=n;i++)
cin>>x[i]>>y[i];
int t=a+b;
for(int i=1;i<=n;i++)
{
if(x[i]>t)
y[i]=s+1;
}
sort(y+1,y+n+1);
for(int i=1;i<=n;i++)
{
if(s>=y[i])
{
ans++;
s-=y[i];
}
else break;
}
cout<<ans<<endl;
return 0;
}
by BookofDeath @ 2019-03-03 22:37:25
多谢