社区讨论
70pts求条
P14635[NOIP2025] 糖果店参与者 2已保存回复 1
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @miuajkkf
- 此快照首次捕获于
- 2025/12/06 20:49 2 个月前
- 此快照最后确认于
- 2025/12/09 13:30 2 个月前
rt。我知道我写假了 但是我不会改。
还有我好奇为什么可以冲过n<=100的所有点qwq
CPP还有我好奇为什么可以冲过n<=100的所有点qwq
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
ll m;
struct candy{
int x,y;
ll num;
}a[100005];
bool cmp1(candy p,candy q){
return p.num<q.num||p.num==q.num&&p.x<q.x;
}
bool cmp2(candy p,candy q){
return p.x<q.x||p.x==q.x&&p.num<q.num;
}
ll ans1=0,ans2=0;
int main(){
//freopen("candy.in","r",stdin);
//freopen("candy.out","w",stdout);
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i].x>>a[i].y;
a[i].num=a[i].x+a[i].y;
}
//A:
/*sort(x+1,x+1+n);
cout<<m/x[1];*/
//B:
sort(a+1,a+1+n,cmp1);
//cout<<a[1].num<<" "<<a[1].x<<" "<<a[1].y<<endl;
ans1=(m%a[1].num>=a[1].x?2*(m/a[1].num)+1:2*(m/a[1].num));
//a<b:
//ll num1=
candy qaq;
qaq.num=200000005;
sort(a+1,a+1+n,cmp2);
for(int i=1;i<=n;i++){
if(qaq.num>a[i].num){
qaq=a[i];
}
//num1=min(num1,a[i].num);
if(m>=a[i].x){
m-=a[i].x;
ans2++;
}
else
{
break;
}
}
sort(a+1,a+n+1,cmp1);
if(a[1].num==qaq.num&&a[1].x==qaq.x)
{
m+=a[1].x;
ans2--;
}
ans2+=(m%a[1].num>=a[1].x?2*(m/a[1].num)+1:2*(m/a[1].num));
cout<<max(ans1,ans2);
return 0;
}
回复
共 1 条回复,欢迎继续交流。
正在加载回复...