結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
ty70
|
| 提出日時 | 2015-05-25 12:16:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,118 bytes |
| コンパイル時間 | 1,002 ms |
| コンパイル使用メモリ | 104,436 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-06 08:17:44 |
| 合計ジャッジ時間 | 3,411 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 RE * 14 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cstdlib> // require abs exit atof atoi
#include <cstdio> // require scanf printf
#include <functional>
#include <numeric> // require accumulate
#include <cmath> // require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip> // require setw
#include <sstream> // require stringstream
#include <cstring> // require memset
#include <cctype> // require tolower, toupper
#include <fstream> // require freopen
#include <ctime> // require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<char,int> CI;
int solve (string s, int G, int C, int P ){
int res = 0;
rep (i, s.length() ){
if (s[i] == 'C' ){
if (G > 0 ){
res += 3; G--;
}else
if (C > 0 ){
res += 1; C--;
}else{
P--;
} // end if
}else
if (s[i] == 'G' ){
if (P > 0 ){
res += 3; P--;
}else
if (G > 0 ){
res += 1; G--;
}else{
C--;
} // end if
}else{ // if (s[i] == 'P' )
if (C > 0 ){
res += 3; C--;
}else
if (P > 0 ){
res += 1; P--;
}else{
G--;
} // end if
} // end if
} // end rep
return res;
}
map<char,int> rank_hand;
bool cmp (CI a, CI b ){
return a.second <= b.second;
}
int main()
{
ios_base::sync_with_stdio(0);
int G, C, P; cin >> G >> C >> P;
string s; cin >> s;
string order = "CGP";
int res = 0;
do{
rank_hand.clear();
rep (i, order.length() ) rank_hand[order[i]] = i;
vector<CI> curr; curr.clear();
rep (i, s.length() ){
char t = s[i];
int r = rank_hand[s[i]];
curr.push_back (CI (t, r ) );
} // end rep
sort (ALL (curr ), cmp );
string u = "";
rep (i, s.length() ) u += curr[i].first;
// cerr << u << endl;
int cur = solve (u, G, C, P );
res = max (res, cur );
}while (next_permutation(ALL (order ) ) );
cout << res << endl;
return 0;
}
ty70