結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
data9824
|
| 提出日時 | 2015-05-25 12:35:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 677 bytes |
| コンパイル時間 | 455 ms |
| コンパイル使用メモリ | 59,028 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 04:36:31 |
| 合計ジャッジ時間 | 1,176 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
int yuki[3];
cin >> yuki[0] >> yuki[1] >> yuki[2];
string s;
cin >> s;
int comp[3];
comp[0] = count(s.begin(), s.end(), 'G');
comp[1] = count(s.begin(), s.end(), 'C');
comp[2] = count(s.begin(), s.end(), 'P');
int point = 0;
int newYuki[3], newComp[3];
for (int i = 0; i < 3; ++i) {
int count = min(yuki[i], comp[(i + 1) % 3]);
point += count * 3;
newYuki[i] = yuki[i] - count;
newComp[(i + 1) % 3] = comp[(i + 1) % 3] - count;
}
for (int i = 0; i < 3; ++i) {
int count = min(newYuki[i], newComp[i]);
point += count;
}
cout << point << endl;
return 0;
}
data9824