結果
問題 |
No.39 桁の数字を入れ替え
|
ユーザー |
![]() |
提出日時 | 2019-07-13 09:54:21 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 544 bytes |
コンパイル時間 | 497 ms |
コンパイル使用メモリ | 60,372 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 13:46:07 |
合計ジャッジ時間 | 1,234 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 5 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <string> using namespace std; typedef long long ll; #define rep(i,n) for (int i = 0; i < (n); ++i) int main(){ string N; cin >> N; char max_num = '0'; int max_ix = 0; for(int i=0;i<N.length();i++){ if(max_num <= N[i]){ max_num = N[i]; max_ix = i; } } for(int i=0;i<N.length();i++){ if(max_num != N[i]){ swap(N[i],N[max_ix]); break; } } cout << N << endl; }