結果

問題 No.2434 RAKUTAN de RAKUTAN
ユーザー noya2
提出日時 2023-08-12 00:42:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 798 bytes
コンパイル時間 2,190 ms
コンパイル使用メモリ 198,552 KB
最終ジャッジ日時 2025-02-16 02:33:01
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 RE * 5 MLE * 1 -- * 11
権限があれば一括ダウンロードができます

ソースコード

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