結果

問題 No.2434 RAKUTAN de RAKUTAN
ユーザー Astral__Astral__
提出日時 2023-08-12 09:33:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,161 bytes
コンパイル時間 2,314 ms
コンパイル使用メモリ 207,476 KB
実行使用メモリ 814,444 KB
最終ジャッジ日時 2024-04-30 11:15:14
合計ジャッジ時間 6,719 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 595 ms
415,392 KB
testcase_04 AC 589 ms
415,224 KB
testcase_05 AC 584 ms
415,296 KB
testcase_06 AC 592 ms
415,344 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 MLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i, s, f) for(ll i = s; i <= f; i++)
typedef int ll;
using namespace std;

void solve() {
   ll N, H, X;
  cin >> N >> H >> X;
  ll G, B;
  cin >> G;
  vector<ll> g(G+1);
  for(int i = 1; i <= G; i++) {
    cin >> g.at(i);
   
  }
  cin >> B;
  vector<ll> b(B+1);
  for(int i = 1; i <= B; i++) {
    cin >> b.at(i);
  }
  H = min(200, H);

  vector<ll> table(N+1, 0);
  rep(i, 1, G){
    table.at(g.at(i)) = 1;
  }
  rep(i, 1, B) {
    table.at(b.at(i)) = -1;
  }

  vector<vector<ll>> dp(N+1, vector<ll>(H+1, -100100100));
  dp.at(0).at(H) = 0;
  rep(i, 1, N) {
    rep(j, 0, H) {
      dp[i][j] = max(dp[i-1][j] + table[i], dp[i][j]);
      if(j != H && i >= X) dp[i][j] = max(dp[i][j], dp[i-X][j+1] + table[i]);
    }
  }

  ll ans = -100100100;
  rep(i, 0, H) {
    ans = max(ans, dp.at(N).at(i));
  }
  cout << ans << endl;

}
//stringでの数字の下から1桁目は 正:S.at(N-1)  誤:S.at(0)
//if(S.at(i) == 1 ← charなのに1...?
// modは取りましたか...?(´・ω・`)



int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}
0