結果
問題 |
No.39 桁の数字を入れ替え
|
ユーザー |
![]() |
提出日時 | 2020-10-11 14:26:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 671 bytes |
コンパイル時間 | 1,911 ms |
コンパイル使用メモリ | 202,416 KB |
最終ジャッジ日時 | 2025-01-15 06:36:59 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; 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; }