結果
問題 |
No.39 桁の数字を入れ替え
|
ユーザー |
|
提出日時 | 2016-03-14 03:45:02 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 632 bytes |
コンパイル時間 | 603 ms |
コンパイル使用メモリ | 65,900 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-25 11:55:10 |
合計ジャッジ時間 | 1,326 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 8 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <utility> int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); char tmp; std::vector<int> input; while (std::cin >> tmp) { input.push_back(tmp-'0'); } std::vector<int> max_checker(input); std::sort(max_checker.begin(), max_checker.end()); std::reverse(max_checker.begin(), max_checker.end()); for (std::vector<int>::reverse_iterator it = input.rbegin(); it != input.rend(); ++it) { if (*it == max_checker[0]) { std::swap(input[0], *it); break; } } for (auto it : input) { std::cout << it; } std::cout << "\n"; return 0; }