結果
問題 | No.2734 Addition and Multiplication in yukicoder (Hard) |
ユーザー |
![]() |
提出日時 | 2024-04-20 00:32:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 668 ms / 5,000 ms |
コード長 | 729 bytes |
コンパイル時間 | 794 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 146,028 KB |
最終ジャッジ日時 | 2024-10-11 19:33:35 |
合計ジャッジ時間 | 14,153 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
from collections import dequedef cmp_to_key(a, b):return a + b <= b + adef 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 Ldef mergeSort(A):mid = len(A)//2if len(A) <= 1:return AL, R = A[:mid], A[mid:]L = mergeSort(L)R = mergeSort(R)A = merge(L, R)return AN = int(input())A = list(input().split())A = mergeSort(A)ans = 0mod = 998244353for a in A:ans *= pow(10, len(a), mod)ans += int(a)ans %= modprint(ans)