結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー rlangevinrlangevin
提出日時 2024-04-20 00:30:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 832 ms / 5,000 ms
コード長 759 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 141,356 KB
最終ジャッジ日時 2024-04-20 00:30:26
合計ジャッジ時間 15,835 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,504 KB
testcase_01 AC 36 ms
53,632 KB
testcase_02 AC 35 ms
54,016 KB
testcase_03 AC 37 ms
53,504 KB
testcase_04 AC 36 ms
53,760 KB
testcase_05 AC 35 ms
53,760 KB
testcase_06 AC 36 ms
53,504 KB
testcase_07 AC 36 ms
53,376 KB
testcase_08 AC 36 ms
53,376 KB
testcase_09 AC 37 ms
53,632 KB
testcase_10 AC 37 ms
53,248 KB
testcase_11 AC 38 ms
53,888 KB
testcase_12 AC 36 ms
53,888 KB
testcase_13 AC 38 ms
53,760 KB
testcase_14 AC 43 ms
53,248 KB
testcase_15 AC 36 ms
53,376 KB
testcase_16 AC 35 ms
53,632 KB
testcase_17 AC 545 ms
121,808 KB
testcase_18 AC 564 ms
123,088 KB
testcase_19 AC 46 ms
55,680 KB
testcase_20 AC 49 ms
55,552 KB
testcase_21 AC 39 ms
55,680 KB
testcase_22 AC 812 ms
138,472 KB
testcase_23 AC 832 ms
138,508 KB
testcase_24 AC 828 ms
138,768 KB
testcase_25 AC 830 ms
138,604 KB
testcase_26 AC 832 ms
138,204 KB
testcase_27 AC 733 ms
138,472 KB
testcase_28 AC 798 ms
137,004 KB
testcase_29 AC 814 ms
140,772 KB
testcase_30 AC 678 ms
138,192 KB
testcase_31 AC 812 ms
141,356 KB
testcase_32 AC 732 ms
135,960 KB
testcase_33 AC 531 ms
109,984 KB
testcase_34 AC 623 ms
128,688 KB
testcase_35 AC 370 ms
100,400 KB
testcase_36 AC 372 ms
100,152 KB
testcase_37 AC 549 ms
116,304 KB
testcase_38 AC 563 ms
110,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
def cmp_to_key(a, b):
    return str(a) + str(b) <= str(b) + str(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(map(int, input().split()))
A = mergeSort(A)
ans = 0
mod = 998244353
for a in A:
    ans *= pow(10, len(str(a)), mod)
    ans += a
    ans %= mod
    
print(ans)
0