QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#672296#5303. No Bug No Gameji_114514WA 45ms74580kbC++201.0kb2024-10-24 16:20:212024-10-24 16:20:22

Judging History

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

  • [2024-10-24 16:20:22]
  • 评测
  • 测评结果:WA
  • 用时:45ms
  • 内存:74580kb
  • [2024-10-24 16:20:21]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long

using namespace std;

const int N = 3e3 + 10, INF = 1e9 + 7;
int n, k, f[N][N], g[N][N];
vector<int>e[N];

void solve()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        int t; cin >> t;
        while (t--) {
            int x; cin >> x; e[i].push_back(x);
        }
    }
    for (int i = 1; i <= k; i++)g[0][i] = f[0][i] = -INF;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= k; j++)g[i][j] = g[i - 1][j], f[i][j] = g[i - 1][j];
        int p = e[i].size();
        for (int j = p; j <= k; j++)f[i][j] = max(f[i][j], f[i - 1][j - p] + e[i].back()), g[i][j] = max(g[i][j], g[i - 1][j - p] + e[i].back());
        for (int s = 1; s <= p; s++)
        {
            for (int j = s; j <= k; j++)g[i][j] = max(g[i][j], f[i - 1][j - s] + e[i][s - 1]);
        }
    }
    cout << g[n][k] << '\n';
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    while (t--)solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5760kb

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: 45ms
memory: 74580kb

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:

133258186

result:

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