結果
| 問題 |
No.437 cwwゲーム
|
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2016-10-28 22:59:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 295 ms / 2,000 ms |
| コード長 | 848 bytes |
| コンパイル時間 | 599 ms |
| コンパイル使用メモリ | 72,108 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 08:24:27 |
| 合計ジャッジ時間 | 2,444 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
string n; cin >> n;
int ans = 0;
vector<pair<string,int>>vs;
vs.push_back(make_pair(n,0));
while(vs.size()){
for (int i = 0; i < n.size() - 2; i++) {
for (int j = i + 1; j < n.size() - 1; j++) {
for (int k = j + 1; k < n.size(); k++) {
string s = vs[0].first;
int cnt = vs[0].second;
if (s[i] != 'x' && s[j] != 'x' && s[k] != 'x' && s[i] != '0') {
if (s[j] == s[k]) {
if (s[i] == s[j])continue;
cnt += (s[i] - '0') * 100 + (s[j] - '0') * 10 + (s[k] - '0');
s[i] = 'x'; s[j] = 'x'; s[k] = 'x';
vs.push_back(make_pair(s,cnt));
}
}
}
}
}
ans = max(ans, vs[0].second);
vs.erase(vs.begin());
}
cout << ans << endl;
return 0;
}
kurenai3110