QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#696120 | #5303. No Bug No Game | dddfff | RE | 0ms | 3548kb | C++23 | 1.5kb | 2024-10-31 21:35:22 | 2024-10-31 21:35:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
typedef pair<int, int> PII;
const int N = 1e3 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
int T;
ll n, k;
ll f[N][N][1], p[N], w[N][10];
void solve()
{
// code
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 = 1; j <= k; j++)
{
f[i][j][0] = f[i][j][1] = -INF;
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= k; j++)
{
f[i][j][0] = max(f[i][j][0], f[i - 1][j][0]);
f[i][j][1] = max(f[i][j][1], f[i - 1][j][1]);
if (j >= p[i])
{
f[i][j][0] = max(f[i][j][0], f[i - 1][j - p[i]][0] + w[i][p[i]]);
f[i][j][1] = max(f[i][j][1], f[i - 1][j - p[i]][1] + w[i][p[i]]);
}
for (int l = 1; l <= p[i]; l++)
{
if (j >= l)
{
f[i][j][1] = max(f[i][j][1], f[i - 1][j - l][0] + w[i][l]);
}
}
}
}
cout << max(f[n][k][0], f[n][k][1]) << '\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
// cin >> T;
while (T--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
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
Runtime Error
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...