結果
問題 | No.2434 RAKUTAN de RAKUTAN |
ユーザー |
![]() |
提出日時 | 2023-08-12 03:16:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,590 bytes |
コンパイル時間 | 3,349 ms |
コンパイル使用メモリ | 252,272 KB |
最終ジャッジ日時 | 2025-02-16 02:41:21 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | TLE * 1 -- * 23 |
ソースコード
#include<bits/stdc++.h>using namespace std;//* ATCODER#include<atcoder/all>using namespace atcoder;typedef modint998244353 mint;//*//* BOOST MULTIPRECISION#include<boost/multiprecision/cpp_int.hpp>using namespace boost::multiprecision;//*/typedef long long ll;#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)template <typename T> bool chmin(T &a, const T &b) {if (a <= b) return false;a = b;return true;}template <typename T> bool chmax(T &a, const T &b) {if (a >= b) return false;a = b;return true;}template <typename T> T max(vector<T> &a){assert(!a.empty());T ret = a[0];for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);return ret;}template <typename T> T min(vector<T> &a){assert(!a.empty());T ret = a[0];for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);return ret;}template <typename T> T sum(vector<T> &a){T ret = 0;for (int i=0; i<(int)a.size(); i++) ret += a[i];return ret;}int main(){int n, h, x; cin >> n >> h >> x;vector<int> score(n+1);int G; cin >> G;rep(i,0,G){int g; cin >> g;g--;score[g]++;}int B; cin >> B;rep(i,0,B){int b; cin >> b;b--;score[b]--;}vector<vector<int>> dp(n+1, vector<int>(0));dp[0] = vector<int>(n, -1e9);dp[0][0] = 0;rep(i,1,n+1){dp[i] = dp[i-1];rep(j,0,h+1) dp[i][j] += score[i];rep(j,1,h+1){if (i-x >= 0){chmax(dp[i][j], dp[i-x][j-1] + score[i]);}}if (i-x >= 0) vector<int>().swap(dp[i-x]);}cout << max(dp[n]) << endl;}