王熙宇 @ 2018-08-12 00:04:23
using namespace std; long long n,s,a,b,num=0; struct apple { int high,power; }que[1000007]; bool cmp(apple x,apple y) { if(x.power!=y.power) return x.power<y.power; } int main() { //freopen("date.in","r",stdin); //freopen("date.out","w",stdout); cin>>n>>s; cin>>a>>b; for(int i=1;i<=n;i++) cin>>que[i].high>>que[i].power; sort(que+1,que+1+n,cmp); for(int i=1;i<=n;i++) if(a+b>=que[i].high&&s>=que[i].power) { s=s-que[i].power; num++; } cout<<num<<endl; return 0; }
by 王熙宇 @ 2018-08-12 00:07:26
using namespace std;
long long n,s,a,b,num=0;
struct apple
{
int high,power;
}que[1000007];
bool cmp(apple x,apple y)
{
if(x.power!=y.power)
return x.power<y.power;
}
int main() {
//freopen("date.in","r",stdin);
//freopen("date.out","w",stdout);
cin>>n>>s;
cin>>a>>b;
for(int i=1;i<=n;i++)
cin>>que[i].high>>que[i].power;
sort(que+1,que+1+n,cmp);
for(int i=1;i<=n;i++)
if(a+b>=que[i].high&&s>=que[i].power)
{
s=s-que[i].power;
num++;
}
cout<<num<<endl;
return 0;
}
by 花园Serena @ 2018-08-12 07:04:37
希望更丰富的展现?使用Markdown
by MessageBoxA @ 2018-08-12 08:01:45
by Zenurik @ 2018-08-12 08:27:46
by Schrodinger @ 2018-08-12 08:27:47
?
by kkksc02 @ 2018-08-12 08:58:47
希望更丰富的展现?使用Markdown!
by kkksc02 @ 2018-08-12 08:59:11