QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#109550 | #71. Cake 3 | bashkort# | 0 | 5ms | 3748kb | C++20 | 1.0kb | 2023-05-29 17:51:41 | 2024-05-31 13:47:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 101;
ll V[N], C[N];
ll dp[N][N];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
for (int i = 0; i < n; ++i) {
cin >> V[i] >> C[i];
// V[i] -= 2 * C[i];
}
ll ans = -3e18;
for (int s = 0; s < n; ++s) {
for (int x = 0; x < n; ++x) {
fill(dp[x], dp[x] + n, -3e18);
}
dp[s][1] = V[s];
for (int i = s + 1; i < n; ++i) {
for (int p = s; p < i; ++p) {
for (int m = 1; m < k; ++m) {
dp[i][m + 1] = max(dp[i][m + 1], dp[p][m] + V[i] - abs(C[i] - C[p]));
// dp[i][m + 1] = max(dp[i][m + 1], dp[p][m] + V[i] + 2 * min(C[i], C[p]));
}
}
ans = max(ans, dp[i][k] - abs(C[i] - C[s]));
// ans = max(ans, dp[i][k] + 2 * min(C[i], C[s]));
}
}
cout << ans << '\n';
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 3748kb
input:
100 32 671208774 266481733 115497791 342597239 326245300 76223942 528973483 754205900 437996819 995535247 100582194 42402057 771100621 351934207 89058009 81951602 768935397 186435060 842907845 376386254 187943947 59424920 997369107 493642356 455078419 68850493 542835555 938351581 970171972 611243076...
output:
20266317099
result:
wrong answer 1st lines differ - expected: '25580474644', found: '20266317099'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%