QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#600159 | #5005. Geekflix | 333zhan | WA | 0ms | 3728kb | C++20 | 1.7kb | 2024-09-29 15:04:48 | 2024-09-29 15:04:49 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve () {
int n, m;
cin >> n >> m;
vector <int> a (n + 1);
for (int i = 1; i <= n; i ++) {
cin >> a[i];
}
vector <int> b (n + 1);
for (int i = 1; i <= n; i ++) {
cin >> b[i];
}
auto work = [&] () {
vector <int> dp (m + 1);
dp[1] = a[1];
int maxx = 0;
for (int i = 1; i <= n; i ++) {
auto ndp = dp;
for (int j = 2; j <= m; j ++) {
ndp[j] = dp[j - 1];
}
for (int j = 1; j <= m; j ++) {
for (int k = 1; a[i] - (k - 1) * b[i] > 0 && k + 1 <= j; k ++) {
ndp[j] = max (ndp[j], dp[j - k - 1] + k * a[i] - k * (k - 1) / 2 * b[i]);
// if (b[2] == 1 && i == 3 && j == 10 && k == 2) {
// cerr << k * a[i] - k * (k - 1) / 2 * b[i] << '\n';
// }
}
}
dp = move (ndp);
maxx = max (maxx, *max_element (dp.begin (), dp.end ()));
// if (b[2] == 1) {
// for (int j = 1; j <= m; j ++) {
// cerr << dp[j] << " \n"[j == m];
// }
// }
}
return maxx;
};
int ans = work ();
reverse (a.begin () + 2, a.end ());
reverse (b.begin () + 2, b.end ());
ans = max (ans, work ());
cout << ans << '\n';
}
signed main () {
ios::sync_with_stdio (false);
cin.tie (nullptr);
int T = 1;
// cin >> T;
while (T --) {
solve ();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
input:
3 10 10 10 10 5 3 1
output:
67
result:
ok single line: '67'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
5 10 1 2 3 4 5 0 1 2 3 4
output:
16
result:
ok single line: '16'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3728kb
input:
5 5 1 5000 1 1 5000 1 3000 1 1 3000
output:
7001
result:
wrong answer 1st lines differ - expected: '10000', found: '7001'