結果
問題 | No.39 桁の数字を入れ替え |
ユーザー |
![]() |
提出日時 | 2021-04-12 18:10:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 438 bytes |
コンパイル時間 | 476 ms |
コンパイル使用メモリ | 64,520 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 15:01:06 |
合計ジャッジ時間 | 1,287 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 4 |
ソースコード
#include <iostream>using namespace std;int main(){string s;cin>>s;char maxnum ='0';int maxp=0;for(int i=0;i<s.length();i++){maxnum=max(maxnum,s[i]);if(maxnum==s[i])maxp=i;}for(int i=0; i<s.length(); i++){if(s[i]<maxnum){char tmp=s[i];s[i]=s[maxp];s[maxp]=tmp;break;}if(i>=maxp)break;}cout<<s;}