結果
問題 | No.39 桁の数字を入れ替え |
ユーザー |
|
提出日時 | 2024-01-14 05:58:54 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 494 bytes |
コンパイル時間 | 2,374 ms |
コンパイル使用メモリ | 118,528 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-28 01:56:56 |
合計ジャッジ時間 | 1,376 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
// No.39 桁の数字を入れ替え #include <iostream> #include <string> using namespace std; int main() { string N; cin >> N; for (int i = 0; i < N.size(); ++i) { int x = -1; int cur = N[i]; for (int j = N.size() - 1; j >= i + 1; --j) { if (cur < N[j]) { x = j; cur = N[j]; } } if (x != -1) { swap(N[i], N[x]); break; } } cout << N << endl; }