社区讨论
70tp2,求调
P14635[NOIP2025] 糖果店参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mlj03qfc
- 此快照首次捕获于
- 2026/02/12 13:11 上周
- 此快照最后确认于
- 2026/02/14 20:40 5 天前
CPP
#include<bits/stdc++.h>
using namespace std;
long long n,m,x[100001],y[100001];
long long a[100001],ans,ans2;
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>x[i]>>y[i];
a[i]=x[i]+y[i];
}
sort(a+1,a+1+n);
if(m>=a[1]){
ans=(m/a[1])*2;
m%=a[1];
}
if(m==0){
cout<<ans<<endl;
return 0;
}
sort(x+1,x+1+n);
for(int i=1;i<=n;i++){
x[i]=x[i]+x[i-1];
if(m>=x[i]){
ans2=i;
}
else break;
}
cout<<ans+ans2;
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...