結果
問題 |
No.2434 RAKUTAN de RAKUTAN
|
ユーザー |
![]() |
提出日時 | 2023-08-18 23:09:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,241 bytes |
コンパイル時間 | 4,341 ms |
コンパイル使用メモリ | 257,728 KB |
最終ジャッジ日時 | 2025-02-16 10:38:56 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 13 |
ソースコード
#include <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int main(){ int N,H,X; cin>>N>>H>>X; vector<pair<int,int>> t; rep(i,2){ int a; cin>>a; rep(j,a){ int pos; cin>>pos; t.emplace_back(pos,-i*2+1); } } sort(t.begin(),t.end()); int aans = 0; if(t.size()>0 && t.back().first==N){ aans += t.back().second; t.pop_back(); } t.emplace_back(0,0); t.emplace_back(N,0); sort(t.begin(),t.end()); rep(i,t.size()-1){ if(t[i].first+10<t[i+1].first){ t[i+1].first = t[i].first + 10; } } N = t.back().first; H = min(N,H); vector<int> cost(N+1); rep(i,t.size()){ cost[t[i].first] = t[i].second; } vector dp(X+5,vector<int>(H+1,-Inf32)); dp[0][0] = 0; rep(i,N){ dp.push_back(vector<int>(H+1,-Inf32)); rep(j,H+1){ dp[1][j] = max(dp[1][j],dp[0][j]+cost[i+1]); if(i+X<=N&&j!=H){ dp[X][j+1] = max(dp[X][j+1],dp[0][j] + cost[i+X]); } } dp.erase(dp.begin()); } int ans = -Inf32; rep(i,H+1)ans = max(ans,dp[0][i]); //cout<<ans<<' '<<aans<<endl; cout<<ans+aans<<endl; return 0; }