提出 #73074496


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vvvl=vector<vector<vector<long long>>>;
using pl=pair<long long,long long>;
using vpl=vector<pair<long long,long long>>;
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(long long i=(long long)(a);i<(long long)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#include <atcoder/all>
using namespace atcoder;

long long modpow(long long a, long long n, long long mo){long long res=1;while(n>0){if(n&1){res=res*a%mo;}a=a*a%mo;n>>=1;}return res;}
long long Pow(long long a, long long n){long long res=1;while(n>0){if(n&1){res=res*a;}a=a*a;n>>=1;}return res;}

const ll MOD=998244353;
const ll INF=(1ll<<60);
//Nの数字和
long long DigitSum(long long N){
    long long Ans=0;
    while(N>0){Ans+=N%10; N/=10;}
    return Ans;
}
int main(){
  ll N;
  cin>>N;
  ll M=2*100000+9;
  vl A(N);
  rep(i,N) cin>>A[i];
  vl kazu(M,0);
  rep(i,N){
    kazu[A[i]]++;
  }
  rep(i,M-1){
    kazu[i+1]+=kazu[i]/10;
    kazu[i]%=10;
  }
  ll hiku=N;
  rep(i,M-1){
    ll nh=hiku%10;
    if(kazu[i]>=nh) kazu[i]-=nh;
    else{
      kazu[i]=10+kazu[i]-nh;
      hiku+=10;
    }
    hiku/=10;
  }
  vl kazug(M,0);
  for(ll i=M-1;i>=0;i--){
    kazug[i]=kazu[i]/9;
    if(i>0) kazu[i-1]+=(kazu[i]%9)*10;
  }
  ll sa=M-1;
  while(kazug[sa]==0) sa--;
  while(sa>=0){
    cout<<kazug[sa];
    sa--;
  }
  cout<<endl;
}

提出情報

提出日時
問題 D - Many Repunit Sum
ユーザ number_cat
言語 C++23 (GCC 15.2.0)
得点 400
コード長 1712 Byte
結果 AC
実行時間 41 ms
メモリ 8076 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 30
セット名 テストケース
Sample 0_sample_1.txt, 0_sample_2.txt, 0_sample_3.txt
All 0_sample_1.txt, 0_sample_2.txt, 0_sample_3.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 2_1.txt, 2_2.txt, 2_3.txt, 2_4.txt, 2_5.txt, 2_6.txt, 2_7.txt
ケース名 結果 実行時間 メモリ
0_sample_1.txt AC 4 ms 6428 KiB
0_sample_2.txt AC 3 ms 6512 KiB
0_sample_3.txt AC 3 ms 6484 KiB
1_01.txt AC 39 ms 8020 KiB
1_02.txt AC 39 ms 8032 KiB
1_03.txt AC 39 ms 8024 KiB
1_04.txt AC 39 ms 8020 KiB
1_05.txt AC 39 ms 8052 KiB
1_06.txt AC 39 ms 8048 KiB
1_07.txt AC 40 ms 8052 KiB
1_08.txt AC 40 ms 8004 KiB
1_09.txt AC 40 ms 8064 KiB
1_10.txt AC 40 ms 8048 KiB
1_11.txt AC 40 ms 7980 KiB
1_12.txt AC 39 ms 8020 KiB
1_13.txt AC 39 ms 8052 KiB
1_14.txt AC 39 ms 8024 KiB
1_15.txt AC 39 ms 8052 KiB
1_16.txt AC 40 ms 7980 KiB
1_17.txt AC 39 ms 8044 KiB
1_18.txt AC 39 ms 7980 KiB
1_19.txt AC 39 ms 8076 KiB
1_20.txt AC 39 ms 8052 KiB
2_1.txt AC 20 ms 8048 KiB
2_2.txt AC 20 ms 8052 KiB
2_3.txt AC 41 ms 7968 KiB
2_4.txt AC 35 ms 8020 KiB
2_5.txt AC 3 ms 6516 KiB
2_6.txt AC 7 ms 6488 KiB
2_7.txt AC 5 ms 6496 KiB