結果

問題 No.39 桁の数字を入れ替え
ユーザー KKT89
提出日時 2020-07-17 01:33:05
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 774 bytes
コンパイル時間 1,889 ms
コンパイル使用メモリ 106,556 KB
最終ジャッジ日時 2025-01-11 21:42:41
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n; n=s.size();
    for(int i=0;i<n;i++){
        char mx=s[i];
        for(int j=i+1;j<n;j++){
            mx=max(mx,s[j]);
        }
        if(mx>s[i]){
            for(int j=n-1;j>=i+1;j--){
                if(s[j]==mx){
                    swap(s[i],s[j]);
                    break;
                }
            }
            break;
        }
    }
    cout << s << endl;
}
0