社区讨论
刷水题蜜汁RE
P1478陶陶摘苹果(升级版)参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mi6mngyh
- 此快照首次捕获于
- 2025/11/20 07:22 4 个月前
- 此快照最后确认于
- 2025/11/20 07:22 4 个月前
本来以为很快可以水过去的题竟然炸掉了。。
两个点RE、、、
跑到sort那里就炸掉了、、、
求解
CPP#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct data
{
int hight;
int powr;
}app[5024];
int n,s,a,b;
int ans,ss;
int com(data xx,data yy)
{
return xx.powr<=yy.powr;
}
int main()
{
freopen("1478.in","r",stdin);
freopen("1478.out","w",stdout);
ans=0;
ss=0;
scanf("%d%d",&n,&s);
scanf("%d%d",&a,&b);
for(int i=1;i<=n;i++) scanf("%d%d",&app[i].hight,&app[i].powr);
sort(app+1,app+1+n,com);
cout<<"~"<<endl;
for(int i=1;i<=n;i++)
{
if(s>=ss+app[i].powr && a+b>=app[i].hight)
{
ss+=app[i].powr;
ans++;
}
}
printf("%d\n",ans);
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...