結果

問題 No.161 制限ジャンケン
ユーザー beetbeet
提出日時 2018-08-09 15:16:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 163 ms / 5,000 ms
コード長 759 bytes
コンパイル時間 1,525 ms
コンパイル使用メモリ 168,768 KB
実行使用メモリ 292,128 KB
最終ジャッジ日時 2023-10-24 12:15:03
合計ジャッジ時間 5,483 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
292,076 KB
testcase_01 AC 155 ms
292,124 KB
testcase_02 AC 153 ms
292,124 KB
testcase_03 AC 161 ms
292,124 KB
testcase_04 AC 152 ms
292,124 KB
testcase_05 AC 147 ms
292,124 KB
testcase_06 AC 159 ms
292,128 KB
testcase_07 AC 148 ms
292,124 KB
testcase_08 AC 158 ms
292,128 KB
testcase_09 AC 146 ms
292,124 KB
testcase_10 AC 147 ms
292,128 KB
testcase_11 AC 148 ms
292,128 KB
testcase_12 AC 148 ms
292,124 KB
testcase_13 AC 156 ms
292,128 KB
testcase_14 AC 147 ms
292,128 KB
testcase_15 AC 152 ms
292,128 KB
testcase_16 AC 149 ms
292,128 KB
testcase_17 AC 149 ms
292,128 KB
testcase_18 AC 148 ms
292,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
Int dp[333][333][333];
signed main(){
  Int g,c,p;
  string s;
  cin>>g>>c>>p>>s;
  Int n=s.size();
  memset(dp,-1,sizeof(dp));
  dp[0][0][0]=0;
  for(Int i=0;i<n;i++){
    for(Int x=0;x<=g;x++){
      for(Int y=0;y<=c;y++){
	Int z=i-(x+y);
	if(z<0||i<z) continue;
	chmax(dp[i+1][x+1][y],dp[i][x][y]+(s[i]=='C')*3+(s[i]=='G'));
	chmax(dp[i+1][x][y+1],dp[i][x][y]+(s[i]=='P')*3+(s[i]=='C'));
	chmax(dp[i+1][x][y],dp[i][x][y]+(s[i]=='G')*3+(s[i]=='P'));		
      }
    }
  }
  cout<<dp[n][g][c]<<endl;
  return 0;
}
0