HOW B?
查看原帖
HOW B?
1358614
__Accepted_cyx__楼主2025/7/27 17:38
#include<bits/stdc++.h>
using namespace std;
const int M=5e5+5;
int n,m,c[M],s[M];
bool e[M];

int len(int x){
    return x<10?1:x<100?2:x<1000?3:x<10000?4:x<100000?5:6;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>c[i];
    for(int i=0;i<n;i++){
        int f=c[i];
        if(!e[f])e[f]=1;
        int l=0,cnt=0;
        for(int j=1;j<=m;j++)
            if(e[j])l+=len(j),cnt++;
        s[f]=l+cnt-1;
    }
    for(int i=1;i<=m;i++)cout<<s[i]<<" \n"[i==m];
    return 0;
}

70 TLE后三个点

2025/7/27 17:38
加载中...