結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2015-03-07 01:10:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 601 bytes |
| コンパイル時間 | 496 ms |
| コンパイル使用メモリ | 64,028 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-30 04:28:06 |
| 合計ジャッジ時間 | 1,214 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
string s;
getline(cin, s);
stringstream ss(s);
int G, C, P;
ss >> G >> C >> P;
getline(cin, s);
int cnt[256] = {};
for (char c : s) {
cnt[c] += 1;
}
int g = min(G, cnt['C']);
int c = min(C, cnt['P']);
int p = min(P, cnt['G']);
int ans = (g + c + p) * 3;
G -= g, C -= c, P -= p;
cnt['C'] -= g, cnt['P'] -= c, cnt['G'] -= p;
g = min(G, cnt['G']);
c = min(C, cnt['C']);
p = min(P, cnt['P']);
ans += (g + c + p);
cout << ans << endl;
return 0;
}
hotpepsi