QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#739708#5303. No Bug No GameZHYaWA 203ms74360kbC++231.7kb2024-11-12 22:45:242024-11-12 22:45:27

Judging History

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

  • [2024-11-12 22:45:27]
  • 评测
  • 测评结果:WA
  • 用时:203ms
  • 内存:74360kb
  • [2024-11-12 22:45:24]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
void solve()
{
    int n, k;
    cin >> n >> k;
    vector<vector<int>> res(n + 1);
    for (int i = 1; i <= n; i++)
    {
        int p;
        cin >> p;
        res[i].push_back(p);
        for (int j = 1; j <= p; j++)
        {
            int x;
            cin >> x;
            res[i].push_back(x);
        }
    }
    int ans = 0;
    for (int p = 1; p <= 10; p++)
    {
        vector<vector<array<int, 2>>> dp(n + 10, vector<array<int, 2>>(k + 10, {INT_MIN, INT_MIN}));
        dp[0][0][0] = 0;
        for (int i = 1; i <= n; i++)
        {
            int vmax = res[i][0];
            for (int j = k; j >= vmax; j--)
            {
                dp[i][j][0] = max(dp[i - 1][j][0], dp[i - 1][j - vmax][0] + res[i][vmax]);
                if (dp[i][j][0] < 0)
                    dp[i][j][0] = INT_MIN;
                dp[i][j][1] = max(dp[i - 1][j][1], dp[i - 1][j - vmax][1] + res[i][vmax]);
                if (dp[i][j][1] < 0)
                    dp[i][j][1] = INT_MIN;
            }
            if (p <= vmax)
            {
                for (int j = k; j >= p; j--)
                {
                    dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j - p][0] + res[i][p]);
                    if (dp[i][j][1] < 0)
                        dp[i][j][1] = INT_MIN;
                }
            }
        }
        if (dp[n][k][0] > 0)
            ans = max(ans, dp[n][k][0]);
        if (dp[n][k][1] > 0)
            ans = max(ans, dp[n][k][1]);
    }
    cout << ans << endl;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while (t--)
        solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3656kb

input:

4 5
2 1 3
2 1 1
2 3 1
2 1 3

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: -100
Wrong Answer
time: 203ms
memory: 74360kb

input:

3000 3000
10 70562 30723 79371 82224 63977 3362 26909 96449 48163 66159
4 18007 33590 80674 91139
4 10304 31694 70745 50656
10 63090 17226 13187 73881 38137 15237 55750 82751 75854 39658
8 95640 66120 87735 36388 44046 92415 6952 94772
9 60565 27904 98726 87052 35768 25453 14563 34273 92501
10 66332...

output:

68233938

result:

wrong answer 1st numbers differ - expected: '68279788', found: '68233938'