社区讨论
TLE求调
P10355 [PA2024] Znaczki pocztowe参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @lvkvgh1h
- 此快照首次捕获于
- 2024/04/29 19:24 2 年前
- 此快照最后确认于
- 2024/04/29 21:25 2 年前
CPP
#include<bits/stdc++.h>
using namespace std;
int n,m,a[300005],j=1,c[300005];
template<typename type>
inline void read(type &x)
{
x=0;bool flag(0);char ch=getchar();
while(!isdigit(ch)) flag=ch=='-',ch=getchar();
while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
flag?x=-x:0;
}
template<typename type>
inline void write(type x,bool mode=1)
{
x<0?x=-x,putchar('-'):0;static short Stack[50],top(0);
do Stack[++top]=x%10,x/=10; while(x);
while(top) putchar(Stack[top--]|48);
mode?putchar('\n'):putchar(' ');
}
signed main(){
cin>>n;
for(int i=1;i<=n;i++){cin>>a[i];}
sort(a+1,a+n+1);
for(int i=1;i<=n;i++){
if(a[i]==a[i+1]) c[j]++;
else {
c[j]+=1;
j++;
}
}
for(int k=1;k<=n;k++){
if(k==1) cout<<n<<" ";
else{
int sum=0;
for(int i=1;i<j;i++) {
if(c[i]>=k){
if(c[i]%k==0) sum+=c[i];
else sum+=c[i]-(c[i]%k);
}
}cout<<sum<<" ";
}
}
// for(int i=5;i<=n;i++) cout<<0<<" ";
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...