結果
| 問題 | No.2734 Addition and Multiplication in yukicoder (Hard) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-19 22:31:09 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 5,000 ms |
| コード長 | 601 bytes |
| 記録 | |
| コンパイル時間 | 1,428 ms |
| コンパイル使用メモリ | 222,560 KB |
| 実行使用メモリ | 11,956 KB |
| 最終ジャッジ日時 | 2026-07-04 13:08:49 |
| 合計ジャッジ時間 | 3,888 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
#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;
}