結果

問題 No.161 制限ジャンケン
ユーザー delt
提出日時 2019-03-03 22:32:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 701 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 60,688 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 13:18:35
合計ジャッジ時間 1,324 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(void){
  int g, c, p;
  string s;
  cin >> g >> c >> p >> s;
  int eg, ec, ep;
  eg = ec = ep = 0;
  for(int i = 0; i < s.length(); i++){
    if(s[i] == 'G') eg++;
    if(s[i] == 'C') ec++;
    if(s[i] == 'P') ep++;
  }
  int ans = 0;
  int temp;
  temp = min(g, ec);
  ans += temp * 3;
  g -= temp;
  ec -= temp;
  temp = min(c, ep);
  ans += temp * 3;
  c -= temp;
  ep -= temp;
  temp = min(p, eg);
  ans += temp * 3;
  p -= temp;
  eg -= temp;
  temp = min(g, eg);
  ans += temp;
  temp = min(c, ec);
  ans += temp;
  temp = min(p, ep);
  ans += temp;
  cout << ans << endl;
  return 0;
}
0