結果

問題 No.2434 RAKUTAN de RAKUTAN
ユーザー noya2noya2
提出日時 2023-08-12 00:42:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 798 bytes
コンパイル時間 2,184 ms
コンパイル使用メモリ 205,640 KB
実行使用メモリ 814,476 KB
最終ジャッジ日時 2024-04-30 11:13:04
合計ジャッジ時間 6,849 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 576 ms
415,348 KB
testcase_04 AC 572 ms
415,360 KB
testcase_05 AC 571 ms
415,276 KB
testcase_06 AC 570 ms
415,312 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 MLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template <typename T, typename U> inline bool chmax(T &x, U y) { return (x < y) ? (x = y, true) : false; }

int main(){
    int n, h, x; cin >> n >> h >> x;
    h = min(h,200);
    int g; cin >> g;
    vector<int> a(n+1,0);
    while (g--){
        int y; cin >> y;
        a[y]++;
    }
    int b; cin >> b;
    while (b--){
        int y; cin >> y;
        a[y]--;
    }
    vector<vector<int>> dp(n+1,vector<int>(h+1,-1e9));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) for (int j = 0; j <= h; j++) {
        chmax(dp[i+1][j],dp[i][j]+a[i+1]);
        if (i+x <= n && j+1 <= h){
            chmax(dp[i+x][j+1],dp[i][j]+a[i+x]);
        }
    }
    int ans = -1e9;
    for (int i = 0; i <= h; i++) chmax(ans,dp[n][i]);
    cout << ans << endl;
}
0