結果

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

ソースコード

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;
	map<char,int> cnt;
	deque<bool> used(N,false);
	for(int i = N - 1;i >= 0;i--){
		if(used [i] == false && ++cnt [S [i]] == 2){
			cnt [S [i]] = 0;
			int mx = -1;
			FOR(j,0,i){
				if(used [j] == false && S [j] != '0' && S [j] != S [i] && (mx == -1 || S [j] > S [mx])){
					mx = j;
				}
			}
			if(mx == -1) continue;
			used [mx] = true;
			ans += (S [mx] - '0') * 100 + (S [i] - '0') * 11;
		}
	}

	cout << ans << endl;

	return 0;
}
0