結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
iqueue02
|
| 提出日時 | 2019-11-25 20:55:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 767 bytes |
| コンパイル時間 | 1,613 ms |
| コンパイル使用メモリ | 168,468 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-14 14:41:23 |
| 合計ジャッジ時間 | 2,572 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
int main(){
int G, C, P;
string s;
cin >> G >> C >> P >> s;
int res = 0;
int n = sz(s);
vector<int> win(n,0);
rep(i,n) {
if (s[i] == 'G' && P > 0) {
res += 3;
P--;
win[i] = 1;
}
if (s[i] == 'C' && G > 0) {
res += 3;
G--;
win[i] = 1;
}
if (s[i] == 'P' && C > 0) {
res += 3;
C--;
win[i] = 1;
}
}
rep(i,n) {
if (!win[i]) {
if (s[i] == 'G' && G > 0) res++, G--;
if (s[i] == 'C' && C > 0) res++, C--;
if (s[i] == 'P' && P > 0) res++, P--;
}
}
cout << res << endl;
return 0;
}
iqueue02