結果

問題 No.161 制限ジャンケン
ユーザー tktk_snsntktk_snsn
提出日時 2021-03-18 01:16:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 1,271 bytes
コンパイル時間 1,598 ms
コンパイル使用メモリ 169,644 KB
実行使用メモリ 16,000 KB
最終ジャッジ日時 2024-04-27 16:01:46
合計ジャッジ時間 2,166 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
7,296 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 22 ms
16,000 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 22 ms
16,000 KB
testcase_09 AC 2 ms
6,948 KB
testcase_10 AC 5 ms
6,940 KB
testcase_11 AC 5 ms
6,940 KB
testcase_12 AC 4 ms
6,940 KB
testcase_13 AC 18 ms
13,568 KB
testcase_14 AC 6 ms
7,168 KB
testcase_15 AC 11 ms
10,752 KB
testcase_16 AC 6 ms
8,064 KB
testcase_17 AC 7 ms
8,832 KB
testcase_18 AC 4 ms
6,940 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