結果

問題 No.927 Second Permutation
ユーザー kiefer_von_maus
提出日時 2020-01-13 02:27:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 457 bytes
コンパイル時間 1,648 ms
コンパイル使用メモリ 171,016 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-14 09:37:07
合計ジャッジ時間 3,111 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 2 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string x;
	cin >> x;
	int X = atoi(x.c_str());
	int len = x.length();
	int xi[len];
	int ans = 0;
	for(int i = 0; i < len; i++) {
		xi[i] = x[i] - '0';
	}
	sort(xi, xi + len);
	for(int i = len - 1; i >= 2; i--) {
		ans += xi[i] * pow(10, i);
	}
	ans = ans + xi[0] * 10 + xi[1];
	if(ans == X) {
		cout << -1 << endl;
	}else {
		cout << ans << endl;
	}
}
0