結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
コンテスト
ユーザー Caiiiiiiii
提出日時 2024-04-19 22:16:04
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 642 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,300 ms
コンパイル使用メモリ 222,480 KB
実行使用メモリ 12,028 KB
最終ジャッジ日時 2026-07-04 13:02:53
合計ジャッジ時間 3,731 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 1 WA * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

typedef long long LL;
typedef __int128 LLL;

#define FOR(i, ed) for(int i = 0; i <= ed; ++i)

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 < y * p;});

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

}
0