結果

問題 No.161 制限ジャンケン
ユーザー iqueue02iqueue02
提出日時 2019-11-25 20:55:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 767 bytes
コンパイル時間 2,123 ms
コンパイル使用メモリ 164,476 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 15:35:29
合計ジャッジ時間 3,108 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0