QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#600159#5005. Geekflix333zhanWA 0ms3728kbC++201.7kb2024-09-29 15:04:482024-09-29 15:04:49

Judging History

你现在查看的是最新测评结果

  • [2024-09-29 15:04:49]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3728kb
  • [2024-09-29 15:04:48]
  • 提交

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'