結果

問題 No.39 桁の数字を入れ替え
ユーザー satanicsatanic
提出日時 2016-03-14 03:48:14
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 778 bytes
コンパイル時間 681 ms
コンパイル使用メモリ 67,072 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 04:04:57
合計ジャッジ時間 1,401 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0