結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー FplusFplusFFplusFplusF
提出日時 2024-04-05 17:10:35
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 354 ms / 5,000 ms
コード長 1,008 bytes
コンパイル時間 4,076 ms
コンパイル使用メモリ 266,100 KB
実行使用メモリ 119,128 KB
最終ジャッジ日時 2024-04-05 17:10:47
合計ジャッジ時間 10,908 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 232 ms
50,304 KB
testcase_18 AC 287 ms
53,572 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 330 ms
118,688 KB
testcase_23 AC 325 ms
119,128 KB
testcase_24 AC 330 ms
119,060 KB
testcase_25 AC 354 ms
118,800 KB
testcase_26 AC 323 ms
118,844 KB
testcase_27 AC 303 ms
97,696 KB
testcase_28 AC 318 ms
112,080 KB
testcase_29 AC 347 ms
110,704 KB
testcase_30 AC 290 ms
84,784 KB
testcase_31 AC 322 ms
115,708 KB
testcase_32 AC 313 ms
103,960 KB
testcase_33 AC 224 ms
59,388 KB
testcase_34 AC 260 ms
83,368 KB
testcase_35 AC 134 ms
36,036 KB
testcase_36 AC 136 ms
36,984 KB
testcase_37 AC 229 ms
72,744 KB
testcase_38 AC 211 ms
63,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> inline bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    const ll mod=998244353;
    ll n;
    cin >> n;
    vector<string> a(n);
    rep(i,n) cin >> a[i];
    vector<pair<string,string>> v(n);
    rep(i,n){
        string b=a[i];
        rep(j,20) b+=a[i];
        v[i]={b,a[i]};
    }
    sort(all(v));
    string s;
    rep(i,n) s+=v[i].second;
    reverse(all(s));
    ll ans=0,r=1;
    for(auto i:s){
        ans+=(i-'0')*r%mod;
        ans%=mod;
        r*=10;
        r%=mod;
    }
    cout << ans << '\n';
}
0