結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2015-07-15 02:34:20 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 483 bytes |
コンパイル時間 | 444 ms |
コンパイル使用メモリ | 58,320 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 04:45:13 |
合計ジャッジ時間 | 1,184 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
#include<iostream> #include<string> #include<algorithm> using namespace std; int u[3], e[3]; int main(void){ cin >> u[0] >> u[1] >> u[2]; string s; cin >> s; for (char c : s){ if (c == 'G') e[0]++; if (c == 'C') e[1]++; if (c == 'P') e[2]++; } int ans = 0; for (int i = 0; i < 3; i++){ int k = min(u[i], e[(i + 1) % 3]); ans += 3 * k; u[i] -= k; e[(i + 1) % 3] -= k; } for (int i = 0; i < 3; i++){ ans += min(u[i], e[i]); } cout << ans << endl; return 0; }