結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー budou
提出日時 2024-04-20 09:38:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,275 ms / 5,000 ms
コード長 689 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 123,552 KB
最終ジャッジ日時 2024-10-12 05:05:07
合計ジャッジ時間 38,288 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

import typing
import sys
from collections import defaultdict, deque
import heapq
from functools import cmp_to_key
input = lambda: sys.stdin.readline().strip()
inf = 10**18
mod = 998244353
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
# sys.setrecursionlimit(10**6)


def solve():
  def cmp(x, y):
    a = pow(10, len(y))*int(x) + int(y)
    b = pow(10, len(x))*int(y) + int(x)
    if a > b:
      return 1
    if a < b:
      return -1
    return 0

  N = int(input())
  l = input().split()
  l.sort(key=cmp_to_key(cmp))
  ans = 0
  for x in l:
    ans = pow(10, len(x))*ans + int(x)
    ans %= mod
  print(ans)
def main():
  t = 1
  for _ in range(t):
    solve()
main()
0