結果
| 問題 |
No.2434 RAKUTAN de RAKUTAN
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2023-08-18 23:12:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 573 ms / 2,000 ms |
| コード長 | 1,329 bytes |
| コンパイル時間 | 3,578 ms |
| コンパイル使用メモリ | 259,160 KB |
| 最終ジャッジ日時 | 2025-02-16 10:41:51 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#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());
{
vector<int> D(t.size()-1);
rep(i,t.size()-1){
D[i] = t[i+1].first - t[i].first;
D[i] = min(D[i],12);
}
rep(i,t.size()-1){
t[i+1].first = t[i].first + D[i];
}
}
N = t.back().first;
H = min(N,H);
vector<int> cost(N+10);
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;
}
沙耶花