結果
| 問題 |
No.39 桁の数字を入れ替え
|
| コンテスト | |
| ユーザー |
weaken
|
| 提出日時 | 2020-10-11 14:28:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 702 bytes |
| コンパイル時間 | 2,165 ms |
| コンパイル使用メモリ | 202,516 KB |
| 最終ジャッジ日時 | 2025-01-15 06:37:19 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 8 |
ソースコード
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
using namespace std;
int main() {
fastIO;
string src;
cin >> src;
size_t maxv = 0;
for (const auto ch : src) {
maxv = max(maxv, (size_t)(ch - '0'));
}
vector<size_t> idxs;
for (size_t i = 0; i < src.size(); ++i) {
if (maxv == (size_t)(src[i] - '0')) {
idxs.emplace_back(i);
}
}
vector<int> res;
res.emplace_back(stoi(src));
for (const auto idx : idxs) {
string dst = src;
char temp = dst[idx];
dst[idx] = dst[0];
dst[0] = temp;
res.emplace_back(stoi(dst));
}
sort(res.begin(), res.end());
cout << res.back() << '\n';
return 0;
}
weaken