結果

問題 No.437 cwwゲーム
ユーザー fine
提出日時 2017-01-06 21:12:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 747 bytes
コンパイル時間 1,570 ms
コンパイル使用メモリ 172,852 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-12 08:41:38
合計ジャッジ時間 2,781 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int solve(vector<int> a) {
	int n = a.size();
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == 0) continue;
		for (int j = i + 1; j < n; j++) {
			if (a[i] == a[j]) continue;
			for (int k = j + 1; k < n; k++) {
				if (a[j] != a[k]) continue;
				vector<int> tmp;
				for (int idx = 0; idx < n; idx++) {
					if (idx == i || idx == j || idx == k) continue;
					tmp.push_back(a[idx]);
				}
				res = max(res, a[i] * 100 + a[j] * 10 + a[k] + solve(tmp));
			}
		}
	}
	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.length();
	vector<int> a(n);
	for (int i = 0; i < n; i++) a[i] = s[i] - '0';
	cout << solve(a) << endl;
	return 0;
}
0