結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー rlangevinrlangevin
提出日時 2024-04-19 23:15:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 711 ms / 5,000 ms
コード長 738 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 146,888 KB
最終ジャッジ日時 2024-04-19 23:15:58
合計ジャッジ時間 14,499 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
53,632 KB
testcase_01 AC 46 ms
53,888 KB
testcase_02 AC 44 ms
53,376 KB
testcase_03 AC 47 ms
53,632 KB
testcase_04 AC 51 ms
53,632 KB
testcase_05 AC 50 ms
53,632 KB
testcase_06 AC 50 ms
53,376 KB
testcase_07 AC 48 ms
53,504 KB
testcase_08 AC 50 ms
53,760 KB
testcase_09 AC 47 ms
53,120 KB
testcase_10 AC 49 ms
53,120 KB
testcase_11 AC 46 ms
53,504 KB
testcase_12 AC 47 ms
53,376 KB
testcase_13 AC 50 ms
53,248 KB
testcase_14 AC 48 ms
53,632 KB
testcase_15 AC 46 ms
53,248 KB
testcase_16 AC 49 ms
53,376 KB
testcase_17 AC 691 ms
128,248 KB
testcase_18 AC 608 ms
128,452 KB
testcase_19 AC 51 ms
55,296 KB
testcase_20 AC 52 ms
55,040 KB
testcase_21 AC 55 ms
55,168 KB
testcase_22 AC 684 ms
142,212 KB
testcase_23 AC 659 ms
141,936 KB
testcase_24 AC 681 ms
142,180 KB
testcase_25 AC 651 ms
142,112 KB
testcase_26 AC 711 ms
142,448 KB
testcase_27 AC 687 ms
144,496 KB
testcase_28 AC 696 ms
139,828 KB
testcase_29 AC 654 ms
142,332 KB
testcase_30 AC 672 ms
142,300 KB
testcase_31 AC 670 ms
146,888 KB
testcase_32 AC 637 ms
138,412 KB
testcase_33 AC 503 ms
119,384 KB
testcase_34 AC 583 ms
130,444 KB
testcase_35 AC 365 ms
106,364 KB
testcase_36 AC 391 ms
107,368 KB
testcase_37 AC 534 ms
121,032 KB
testcase_38 AC 517 ms
122,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
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:
        a = Q[0]
        b = Q[-1]
        if str(a) + str(b) <= str(b) + str(a):
            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())
M = 65
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