比赛 |
20241129 |
评测结果 |
AAAAAAAAAA |
题目名称 |
棋局 |
最终得分 |
100 |
用户昵称 |
┭┮﹏┭┮ |
运行时间 |
0.454 s |
代码语言 |
C++ |
内存使用 |
4.03 MiB |
提交时间 |
2024-11-29 10:49:02 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,ll>
#define fi first
#define in inline
#define se second
#define mp make_pair
#define pb push_back
const int N = 2e5+10;
ll read(){
ll x = 0,f = 1;char c = getchar();
for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
return x * f;
}
ll n,m;
ll a[N],s[N];
bool check(ll mid,ll k){
int p = lower_bound(a+1,a+1+n,mid) - a;
return (ll)(k - 1) * (m - mid) >= (ll)s[p] - (n - p + 1) * mid;
}
int main(){
freopen("qiju.in","r",stdin);
freopen("qiju.out","w",stdout);
n = read(),m = read();
for(int i = 1;i <= n;i++)a[i] = read();
sort(a+1,a+1+n);
for(int i = n;i >= 1;i--)s[i] = s[i+1] + a[i];
for(int i = 1;i <= n;i++){
ll l = 0,r = m;
while(l < r){
ll mid = l + r >> 1;
if(check(mid,i))r = mid;
else l = mid + 1;
}
printf("%lld ",l);
}
printf("\n");
return 0;
}