QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789817#8034. Ban or Pick, What's the TrickjieloscWA 1ms5768kbC++201.3kb2024-11-27 22:04:372024-11-27 22:04:39

Judging History

This is the latest submission verdict.

  • [2024-11-27 22:04:39]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5768kb
  • [2024-11-27 22:04:37]
  • Submitted

answer

#include <bits/stdc++.h>
#define int int64_t

using std::cin;
using std::cout;
const char endl = '\n';
const int maxn = (int)1.1E5;

int n, k;
int a[maxn], b[maxn];

int dp[maxn * 2][13][13];
bool vis[maxn * 2][11][11];

int dfs(int u, int k1, int k2) {
  if (u >= n * 2) return 0;
  if (vis[u][k1][k2]) return dp[u][k1][k2];
  vis[u][k1][k2] = 1;
  int &d = dp[u][k1][k2];
  if ((u & 1) == 0) {
    if(k1 + 1 <= k and n - (u / 2 - k2) - k1 >= 1) d = dfs(u + 1, k1 + 1, k2) + a[n - (u / 2 - k2) - k1];
    // if(k2 + u/2 - k1 < n) 
    d = std::max(d, dfs(u + 1, k1, k2));
    return d;
  } else {
    if(k2 + 1 <= k and n - ((u+1)/2 - k1) - k2 >= 1) d = dfs(u + 1, k1, k2 + 1) - b[n - ((u+1)/2 - k1) - k2];
    // if (k1 + u/2 - k2 < n) 
    d = std::min(d, dfs(u + 1, k1, k2));
    return d;
  }
}

void solve() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) cin >> b[i];
  std::sort(a + 1, a + 1 + n);
  std::sort(b + 1, b + 1 + n);
  cout << dfs(0, 0, 0) << endl;
}

int32_t main() {
#ifndef _DEBUG
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
#endif
  int tc = 1;
  // std::cin >> tc;
  while (tc--) solve();
#ifdef _DEBUG
  std::cout << std::endl;
  std::cout << "Time used: " << clock() << "ms" << std::endl;
  system("pause");
  return 0;
#endif
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5692kb

input:

2 1
3 6
2 4

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

4 1
1 3 5 7
2 4 6 8

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 1ms
memory: 5768kb

input:

4 2
4 6 7 9
2 5 8 10

output:

3

result:

ok single line: '3'

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 5668kb

input:

10 5
42 13 60 42 100 82 22 98 14 55
100 41 89 24 65 38 69 26 37 16

output:

45

result:

wrong answer 1st lines differ - expected: '41', found: '45'