結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー LyricalMaestro
提出日時 2024-11-26 00:42:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,722 ms / 5,000 ms
コード長 564 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 127,072 KB
最終ジャッジ日時 2024-11-26 00:43:13
合計ジャッジ時間 27,867 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

## 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