結果

問題 No.161 制限ジャンケン
ユーザー 0w10w1
提出日時 2016-11-20 20:40:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 1,475 ms
コンパイル使用メモリ 165,540 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-18 05:52:17
合計ジャッジ時間 3,068 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

signed main(){
  int G, C, P; cin >> G >> C >> P;
  string S; cin >> S;
  int ans = 0;
  int a = 0, b = 0, c = 0;
  for( int i = 0; i < S.size(); ++i )
    a += S[ i ] == 'G',
    b += S[ i ] == 'C',
    c += S[ i ] == 'P';
  int f;
  ans += min( G, b ); f = min( G, b ), G -= f, b -= f;
  ans += min( C, c ), f = min( C, c ), C -= f, c -= f;
  ans += min( P, a ), f = min( P, a ), P -= f, a -= f;
  ans += min( G, a ) + min( C, b ) + min( P, c );
  cout << ans << endl;
  return 0;
}
0