結果

問題 No.161 制限ジャンケン
ユーザー nenuon
提出日時 2017-07-15 16:53:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 843 bytes
コンパイル時間 736 ms
コンパイル使用メモリ 88,572 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-30 05:17:17
合計ジャッジ時間 1,448 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int g,c,p;
  cin>>g>>c>>p;
  string s;cin>>s;
  int gg = 0,cc = 0,pp = 0;
  FOR(i,0,s.length()) {
    if(s[i]=='G') gg++;
    if(s[i]=='C') cc++;
    if(s[i]=='P') pp++;
  }
  int ans = 0;
  int mn = min(g, cc);
  ans += mn * 3;
  g -= mn;
  cc -= mn;

  mn = min(c, pp);
  ans += mn * 3;
  c -= mn;
  pp -= mn;

  mn = min(p, gg);
  ans += mn * 3;
  p -= mn;
  gg -= mn;

  // aiko
  ans += min(g, gg);
  ans += min(c, cc);
  ans += min(p, pp);
  printf("%d\n", ans);
  return 0;
}
0