結果
| 問題 | No.39 桁の数字を入れ替え |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-01 18:18:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 548 bytes |
| 記録 | |
| コンパイル時間 | 446 ms |
| コンパイル使用メモリ | 58,640 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-02 07:04:15 |
| 合計ジャッジ時間 | 1,110 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <iostream>
#include <cstdint>
#include <string>
#include <algorithm>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string n;
cin >> n;
string ans = n;
string temp = n;
for (size_t i = 0; i < n.size(); i++) {
for (size_t j = i + 1; j < n.size(); j++) {
if (n.at(i) < n.at(j)) {
swap(temp.at(i), temp.at(j));
ans = max(ans, temp);
temp = n;
}
}
}
cout << ans << endl;
return 0;
}