結果
問題 |
No.161 制限ジャンケン
|
ユーザー |
![]() |
提出日時 | 2016-09-03 15:56:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,170 bytes |
コンパイル時間 | 1,270 ms |
コンパイル使用メモリ | 81,388 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-15 18:50:58 |
合計ジャッジ時間 | 1,550 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 10 |
ソースコード
#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; G = 0; count[1] -= G; } if(C > count[2]){ point += count[2]*3; C = C - count[2]; count[2] = 0; }else{ point += C*3; C = 0; count[2] -= C; } if(P > count[0]){ point += count[0]*3; P = P - count[0]; count[0] = 0; }else{ point += P*3; P = 0; count[1] -= P; } 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; }