QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#752200#5303. No Bug No GameBIOSOIBWA 82ms74400kbC++201.2kb2024-11-15 22:53:152024-11-15 22:53:15

Judging History

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

  • [2024-11-15 22:53:15]
  • 评测
  • 测评结果:WA
  • 用时:82ms
  • 内存:74400kb
  • [2024-11-15 22:53:15]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 3015;
int dp[N][N][2], n, k, w[N][11], p[N], res;
signed main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> p[i];
        for (int j = 1; j <= p[i]; j++)
            cin >> w[i][j];
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= k; j++)
        {
            dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][0]);
            dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][1]);
            if (j >= p[i])
            {
                dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j - p[i]][1] + w[i][p[i]]);
                dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j - p[i]][0] + w[i][p[i]]);
            }
            for (int tmp = 1; tmp <= p[i]; tmp++)
                if (j >= tmp)
                    dp[i][j][1] = max(dp[i][j][1], dp[i][j - tmp][0] + w[i][tmp]);
        }
    }
    for (int i = 1; i <= n; i++)
        for (int j = 0; j <= k; j++)
        {
            res = max(res, dp[i][j][0]);
            if (j == k)
                res = max(res, dp[i][j][1]);
        }
    cout << res << endl;
}

详细

Test #1:

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

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: 0
Accepted
time: 68ms
memory: 74400kb

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:

68279788

result:

ok 1 number(s): "68279788"

Test #3:

score: -100
Wrong Answer
time: 82ms
memory: 74400kb

input:

3000 3000
7 63414 1471 67699 90007 79945 68096 24021
8 88988 13255 69503 8350 23580 4589 13918 43025
2 7666 45786
2 23237 48565
9 46170 76160 31929 26707 99 76847 64227 82880 99490
8 45937 52389 61039 13440 76101 49424 68485 47682
4 71757 34559 95339 27693
10 55332 93329 61008 26946 44148 73675 3776...

output:

70716942

result:

wrong answer 1st numbers differ - expected: '70716917', found: '70716942'