結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-20 20:41:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 543 bytes |
| コンパイル時間 | 1,521 ms |
| コンパイル使用メモリ | 167,868 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-30 05:07:01 |
| 合計ジャッジ時間 | 2,237 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
signed main(){
int G, C, P; cin >> G >> C >> P;
string S; cin >> S;
int ans = 0;
int a = 0, b = 0, c = 0;
for( int i = 0; i < S.size(); ++i )
a += S[ i ] == 'G',
b += S[ i ] == 'C',
c += S[ i ] == 'P';
int f;
ans += 3 * min( G, b ); f = min( G, b ), G -= f, b -= f;
ans += 3 * min( C, c ), f = min( C, c ), C -= f, c -= f;
ans += 3 * min( P, a ), f = min( P, a ), P -= f, a -= f;
ans += min( G, a ) + min( C, b ) + min( P, c );
cout << ans << endl;
return 0;
}