結果
| 問題 |
No.39 桁の数字を入れ替え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-14 03:48:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 778 bytes |
| コンパイル時間 | 627 ms |
| コンパイル使用メモリ | 66,296 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-25 11:55:20 |
| 合計ジャッジ時間 | 1,172 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 5 |
ソースコード
#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]) {
for (std::vector<int>::iterator it2 = input.begin(); it2 != input.end(); ++it2) {
if (*it2 != max_checker[0]) {
std::swap(*it, *it2);
goto OUTPUT;
}
}
}
}
OUTPUT:
for (auto it : input) {
std::cout << it;
}
std::cout << "\n";
return 0;
}