Educational Codeforces Round 127 (Rated for Div. 2)

其实这个题数据大一点也可以的 根据小凯的疑惑这道题结论 n,m 最小不能组合的数为n×m-m-n

那么对于2 3 最小不能合成的数为1 所以特判一下1 剩下所有的数都可以组合出来

如果出现三个及以上 连续的段相差为1一定不满足题意

如果要出现连续的段相差为2 就有且仅有两个连续段

首先排序 考虑每个商店的贡献即可

点击查看代码
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) x&(-x)
#define ll long long
const int maxn=2e5+5;
ll pre[maxn],a[maxn];
int T;
void solve();
int main(){
	cin>>T;
	while(T--)solve();
     return 0;
}
void solve(){
	ll n,x;
	ll res=0;
	cin>>n>>x;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++){
    	pre[i]=pre[i-1]+a[i];
    	if(pre[i]>x)break;
    	res++;
    	res+=(x-pre[i])/i;
	}
	cout<<res<<endl;
}
posted @ 2022-05-06 21:09  wzx_believer  阅读(29)  评论(0)    收藏  举报