結果
問題 |
No.161 制限ジャンケン
|
ユーザー |
![]() |
提出日時 | 2018-03-21 21:04:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,276 bytes |
コンパイル時間 | 615 ms |
コンパイル使用メモリ | 69,376 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-24 19:39:31 |
合計ジャッジ時間 | 1,327 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
// No.161 制限ジャンケン // https://yukicoder.me/problems/no/161 // #include <iostream> #include <vector> using namespace std; int solve(vector<int> &yuki, string &s); int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); vector<int> yuki(3); for (int i = 0; i < 3; ++i) cin >> yuki[i]; string s; cin >> s; int ans = solve(yuki, s); cout << ans << endl; } int solve(vector<int> &yuki, string &s) { const int G = 0; const int C = 1; const int P = 2; vector<int> fri(3, 0); for (char c: s) { if (c == 'G') ++fri[G]; else if (c == 'C') ++fri[C]; if (c == 'P') ++fri[P]; } int ans = 0; // 勝ちによるポイント int g_win = min(yuki[G], fri[C]); int c_win = min(yuki[C], fri[P]); int p_win = min(yuki[P], fri[G]); yuki[G] -= g_win; yuki[C] -= c_win; yuki[P] -= p_win; fri[C] -= g_win; fri[P] -= c_win; fri[G] -= p_win; ans += (g_win + c_win + p_win) * 3; // 引き分けによるポイント int g_draw = min(yuki[G], fri[G]); int c_draw = min(yuki[C], fri[C]); int p_draw = min(yuki[P], fri[P]); ans += (g_draw + c_draw + p_draw); return ans; }