結果
問題 | No.2434 RAKUTAN de RAKUTAN |
ユーザー |
![]() |
提出日時 | 2023-08-12 03:22:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,592 bytes |
コンパイル時間 | 3,412 ms |
コンパイル使用メモリ | 251,368 KB |
最終ジャッジ日時 | 2025-02-16 02:41:59 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 WA * 1 RE * 5 TLE * 4 MLE * 1 -- * 11 |
ソースコード
#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(x+1, vector<int>(h+1, -1e9));dp[0][0] = 0;int piv = 0;rep(i,1,n+1){piv++;piv %= x+1;int prev = (piv+x)%(x+1);int xbak = (piv+1)%(x+1);dp[piv][0] = dp[prev][0] + score[i];rep(j,1,h+1){dp[piv][j] = max(dp[prev][j], dp[xbak][j-1]) + score[i];}}cout << max(dp[piv]) << endl;}