結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
hayaD
|
| 提出日時 | 2016-09-03 16:01:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,170 bytes |
| コンパイル時間 | 639 ms |
| コンパイル使用メモリ | 82,228 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 04:55:34 |
| 合計ジャッジ時間 | 1,409 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()
int main(){
int G,C,P;
cin >> G >> C >> P;
string s;
cin >> s;
int count[3] = {0};
FOR(i,0,s.length()){
if(s[i] == 'G') count[0]++;
else if(s[i] == 'C') count[1]++;
else if(s[i] == 'P') count[2]++;
}
int point = 0;
if(G > count[1]){
point += count[1]*3;
G = G - count[1];
count[1] = 0;
}else{
point += G*3;
count[1] -= G;
G = 0;
}
if(C > count[2]){
point += count[2]*3;
C = C - count[2];
count[2] = 0;
}else{
point += C*3;
count[2] -= C;
C = 0;
}
if(P > count[0]){
point += count[0]*3;
P = P - count[0];
count[0] = 0;
}else{
point += P*3;
count[0] -= P;
P = 0;
}
if(G>0){
point += min(G,count[0]);
}
if(C>0){
point += min(C,count[1]);
}
if(P>0){
point += min(P,count[2]);
}
cout << point << endl;
return 0;
}
hayaD