結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー CaiiiiiiiiCaiiiiiiii
提出日時 2024-04-19 22:31:09
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 96 ms / 5,000 ms
コード長 601 bytes
コンパイル時間 2,173 ms
コンパイル使用メモリ 207,340 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2024-10-11 16:05:20
合計ジャッジ時間 5,346 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long LL;
typedef __int128 LLL;

const int N = 10;
const int MOD = 998244353;

int n;

int main() {

  scanf("%d", &n);
  std::vector<std::pair<LL, LLL>> a(n);
  for(auto &[x, y]: a) {
    scanf("%lld", &x);
    LL t = x;
    y = 1;
    while(t) {
      t /= 10;
      y *= 10;
    }
  }

  std::sort(a.begin(), a.end(), [] (const auto &s, const auto &t) {
				  auto &&[x, y] = s;
				  auto &&[p, q] = t;
				  return x * q + p < y * p + x;});

  int ans = 0;
  for(auto &&[x, y]: a)
    ans = (ans * y + x) % MOD;  
  
  printf("%d\n", ans);
  
  return 0;

}
0