結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-11-28 11:58:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 714 bytes |
| コンパイル時間 | 1,688 ms |
| コンパイル使用メモリ | 167,188 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 11:05:15 |
| 合計ジャッジ時間 | 2,316 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int my_hand[3]; cin >> my_hand[0] >> my_hand[1] >> my_hand[2];
string s; cin >> s;
int opp_hand[3] = {0, 0, 0};
for(int i = 0; i < s.size(); i++) {
if(s[i] == 'G') opp_hand[0]++;
if(s[i] == 'C') opp_hand[1]++;
if(s[i] == 'P') opp_hand[2]++;
}
int ans = 0;
for(int i = 0; i < 3; i++) {
int tmp = min(my_hand[i], opp_hand[(i + 1) % 3]);
ans += 3 * tmp;
my_hand[i] -= tmp;
opp_hand[(i + 1) % 3] -= tmp;
}
for(int i = 0; i < 3; i++) {
ans += min(my_hand[i], opp_hand[i]);
}
cout << ans << endl;
return 0;
}