結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2015-09-05 03:16:32 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 871 bytes |
コンパイル時間 | 599 ms |
コンパイル使用メモリ | 61,256 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 04:45:57 |
合計ジャッジ時間 | 1,309 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #define REP(i,k,n) for(int i=k;i<n;i++) #define rep(i,n) for(int i=0;i<n;i++) using namespace std; int main() { int G,C,P; cin >> G >> C >> P; string s; cin >> s; int ans = 0; int g = 0,c = 0,p = 0; rep(i,s.size()) { if(s[i] == 'G') g++; if(s[i] == 'C') c++; if(s[i] == 'P') p++; } while(G && c) { G--; c--; ans += 3; } while(C && p) { C--; p--; ans += 3; } while(P && g) { P--; g--; ans += 3; } while(G && g) { G--; g--; ans++; } while(C && c) { C--; c--; ans++; } while(P && p) { P--; p--; ans++; } cout << ans << endl; return 0; }