結果

問題 No.161 制限ジャンケン
ユーザー sakasu1sakasu1
提出日時 2020-08-13 13:59:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 720 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 163,452 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-18 01:30:48
合計ジャッジ時間 2,409 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
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 WA -
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 WA -
testcase_12 WA -
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int i,g,c,p;
  string s;
  cin >> g >> c >> p >> s;
  int ans=0;
  for(i=0;i<s.size();i++){
    if(s[i]=='G'){
      if(p>0){
        ans+=3;
        p--;
      }
      else if(g>0){
        ans++;
        g--;
      }
      else{
        c--;
      }
    }
    else if(s[i]=='C'){
      if(g>0){
        ans+=3;
        g--;
      }
      else if(c>0){
        ans++;
        c--;
      }
      else{
        p--;
      }
    }
    else{
      if(c>0){
        ans+=3;
        c--;
      }
      else if(p>0){
        ans++;
        p--;
      }
      else{
        g--;
      }
    }
  }
  cout << ans << endl;
}
0