結果
| 問題 |
No.39 桁の数字を入れ替え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-01 11:43:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 532 bytes |
| コンパイル時間 | 896 ms |
| コンパイル使用メモリ | 68,612 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-20 11:21:42 |
| 合計ジャッジ時間 | 4,926 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 19 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
int N;
cin >> N;
string Ns = to_string(N);
for (int i = 0; i < (int)Ns.size(); ++i) {
int max = Ns[i];
int idx = i;
for (int j = (int)Ns.size() - 1; j >= i + 1; ++j) {
if (max < Ns[j]) {
max = Ns[j];
idx = j;
}
}
if (idx != i) {
swap(Ns[i], Ns[idx]);
break;
}
}
cout << Ns << endl;
}