結果

問題 No.437 cwwゲーム
ユーザー gigime
提出日時 2016-10-29 00:24:05
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 948 bytes
コンパイル時間 1,920 ms
コンパイル使用メモリ 169,076 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 10:53:58
合計ジャッジ時間 2,894 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;
string S;

int main()
{
	cin >> S;
	N = S.size();

	ll ans = 0;
	for(int mask = 1;mask < (1 << N) - 1;mask++){
		ll res = 0;
		map<char,int> cnt;
		deque<bool> used(N,false);
		for(int i = N - 1;i >= 0;i--) if((mask & (1 << i)) == 0 && used [i] == false){
			used [i] = true;
			if(++cnt [S [i]] == 2){
				cnt [S [i]] = 0;
				for(int j = i - 1;j >= 0;j--) if(mask & (1 << j)){
					if(used [j] == false && S [j] != '0' && S [j] != S [i]){
						used [j] = true;
						res += (S [j] - '0') * 100 + (S [i] - '0') * 11;
						break;
					}
				}
			}
		}
		chmax(ans,res);
	}

	cout << ans << endl;

	return 0;
}
0