結果
問題 | No.39 桁の数字を入れ替え |
ユーザー |
![]() |
提出日時 | 2020-10-11 14:57:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 449 bytes |
コンパイル時間 | 1,930 ms |
コンパイル使用メモリ | 193,172 KB |
最終ジャッジ日時 | 2025-01-15 06:38:00 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <algorithm> #include <bits/stdc++.h> #define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false)) using namespace std; int main() { fastIO; string src; cin >> src; int ans = stoi(src); for (size_t i = 0; i < src.size() - 1; ++i) { for (size_t j = i + 1; j < src.size(); ++j) { string copy = src; swap(copy[i], copy[j]); ans = max(ans, stoi(copy)); } } cout << ans << '\n'; return 0; }