結果

問題 No.161 制限ジャンケン
ユーザー tktk_snsntktk_snsn
提出日時 2021-03-18 01:16:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 1,271 bytes
コンパイル時間 1,518 ms
コンパイル使用メモリ 166,404 KB
実行使用メモリ 16,124 KB
最終ジャッジ日時 2023-08-09 21:38:12
合計ジャッジ時間 2,791 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
7,196 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 24 ms
16,124 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 26 ms
15,968 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 4 ms
5,796 KB
testcase_11 AC 6 ms
6,628 KB
testcase_12 AC 4 ms
5,396 KB
testcase_13 AC 20 ms
13,560 KB
testcase_14 AC 7 ms
7,344 KB
testcase_15 AC 12 ms
10,844 KB
testcase_16 AC 8 ms
7,956 KB
testcase_17 AC 8 ms
8,728 KB
testcase_18 AC 4 ms
5,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; }

int dp[301][301][301];

int main(){
    int gg, cc, pp; 
    cin >> gg >> cc >> pp;
    string s;
    cin >> s;
    for (int i=0; i<s.size(); ++i) {
        for (int g=0; g<=gg; ++g) {
            for (int c=0; c<=cc; ++c) {
                int p = i - c - g;
                if (p > pp || p < 0) continue;
                if (s[i]=='G') {
                    chmax(dp[g+1][c][p], dp[g][c][p]+1);
                    chmax(dp[g][c+1][p], dp[g][c][p]);
                    chmax(dp[g][c][p+1], dp[g][c][p]+3);
                }
                else if (s[i]=='C') {
                    chmax(dp[g+1][c][p], dp[g][c][p]+3);
                    chmax(dp[g][c+1][p], dp[g][c][p]+1);
                    chmax(dp[g][c][p+1], dp[g][c][p]);
                }
                else {
                    chmax(dp[g+1][c][p], dp[g][c][p]);
                    chmax(dp[g][c+1][p], dp[g][c][p]+3);
                    chmax(dp[g][c][p+1], dp[g][c][p]+1);
                }
            }
        }
    }
    cout << dp[gg][cc][pp] << endl;
}
0