結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー rlangevinrlangevin
提出日時 2024-04-20 00:32:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 622 ms / 5,000 ms
コード長 729 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 82,204 KB
実行使用メモリ 146,168 KB
最終ジャッジ日時 2024-04-20 00:32:37
合計ジャッジ時間 12,451 ms
ジャッジサーバーID
(参考情報)
judge6 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,504 KB
testcase_01 AC 38 ms
53,888 KB
testcase_02 AC 35 ms
53,376 KB
testcase_03 AC 39 ms
54,016 KB
testcase_04 AC 37 ms
53,632 KB
testcase_05 AC 37 ms
53,376 KB
testcase_06 AC 36 ms
53,504 KB
testcase_07 AC 38 ms
53,632 KB
testcase_08 AC 34 ms
54,016 KB
testcase_09 AC 39 ms
53,632 KB
testcase_10 AC 36 ms
53,632 KB
testcase_11 AC 37 ms
53,760 KB
testcase_12 AC 36 ms
54,016 KB
testcase_13 AC 35 ms
53,760 KB
testcase_14 AC 37 ms
53,760 KB
testcase_15 AC 38 ms
53,632 KB
testcase_16 AC 36 ms
53,888 KB
testcase_17 AC 527 ms
128,884 KB
testcase_18 AC 547 ms
128,124 KB
testcase_19 AC 38 ms
55,040 KB
testcase_20 AC 38 ms
55,040 KB
testcase_21 AC 37 ms
54,912 KB
testcase_22 AC 588 ms
140,300 KB
testcase_23 AC 596 ms
140,256 KB
testcase_24 AC 581 ms
140,344 KB
testcase_25 AC 601 ms
140,152 KB
testcase_26 AC 571 ms
140,280 KB
testcase_27 AC 616 ms
146,168 KB
testcase_28 AC 576 ms
140,832 KB
testcase_29 AC 622 ms
141,944 KB
testcase_30 AC 578 ms
143,532 KB
testcase_31 AC 603 ms
144,956 KB
testcase_32 AC 566 ms
138,876 KB
testcase_33 AC 426 ms
120,052 KB
testcase_34 AC 538 ms
131,636 KB
testcase_35 AC 308 ms
106,104 KB
testcase_36 AC 337 ms
107,552 KB
testcase_37 AC 471 ms
121,956 KB
testcase_38 AC 456 ms
122,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
def cmp_to_key(a, b):
    return a + b <= b + a

def merge(S, T):
    Q = deque()
    for s in S:
        Q.append(s)
    for t in T[::-1]:
        Q.append(t)
    L = []
    while len(Q) >= 2:
        if cmp_to_key(Q[0], Q[-1]):
            L.append(Q.popleft())
        else:
            L.append(Q.pop())
    L.append(Q.pop())
    return L

def mergeSort(A):
    mid = len(A)//2
    if len(A) <= 1:
        return A
    L, R = A[:mid], A[mid:]
    L = mergeSort(L)
    R = mergeSort(R)
    A = merge(L, R)
    return A

N = int(input())
A = list(input().split())
A = mergeSort(A)
ans = 0
mod = 998244353
for a in A:
    ans *= pow(10, len(a), mod)
    ans += int(a)
    ans %= mod
    
print(ans)
0