結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
コンテスト
ユーザー LyricalMaestro
提出日時 2024-11-26 00:42:41
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 1,070 ms / 5,000 ms
+ 275µs
コード長 564 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 79 ms
コンパイル使用メモリ 64,740 KB
実行使用メモリ 104,912 KB
最終ジャッジ日時 2026-10-21 03:45:37
合計ジャッジ時間 23,875 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

## https://yukicoder.me/problems/no/1612

from functools import cmp_to_key

MOD = 998244353

def cmp_str(a, b):
    a1 = a + b
    a2 = b + a
    if a1 < a2:
        return -1
    elif a1 > a2:
        return 1
    else:
        return 0


def main():
    N = int(input())
    A = input().split()

    A = list(sorted(A, key=cmp_to_key(cmp_str)))

    answer_str = "".join(A)
    answer = 0
    for a in answer_str:
        answer *= 10
        answer %= MOD
        answer += int(a)
        answer %= MOD
    print(answer)



if __name__ == "__main__":
    main()
0