結果

問題 No.2434 RAKUTAN de RAKUTAN
ユーザー Astral__Astral__
提出日時 2023-08-11 18:05:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,190 bytes
コンパイル時間 2,325 ms
コンパイル使用メモリ 208,616 KB
実行使用メモリ 814,600 KB
最終ジャッジ日時 2024-04-30 11:12:06
合計ジャッジ時間 3,476 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 MLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
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 long long ll;
using namespace std;

void solve() {
   ll N, M, X;
  cin >> N >> M >> 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);
  }

  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>(M+1, -100100100));
  dp.at(0).at(M) = 0;
  rep(i, 1, N) {
    rep(j, 0, M) {
      dp.at(i).at(j) = max(dp.at(i-1).at(j) + table.at(i), dp.at(i).at(j));
      if(j != M && i >= X) dp.at(i).at(j) = max(dp.at(i).at(j), dp.at(i-X).at(j+1) + table.at(i));
    }
  }

  ll ans = -100100100;
  rep(i, 0, M) {
    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