QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#722113 | #5303. No Bug No Game | SmHaInT | WA | 3ms | 145052kb | C++20 | 2.3kb | 2024-11-07 17:53:26 | 2024-11-07 17:53:26 |
Judging History
answer
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<string.h>
#include <string>
#include<math.h>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<queue>
#include<stack>
#include<functional>
#include<deque>
using namespace std;
const int MAXN = 3010;
#define int long long
#define ll long long
#define lll unsigned long long
#define PA pair<ll,ll>
#define INF (ll)0x3f3f3f3f*(ll)1000000
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9 + 7;
int dp[MAXN][MAXN][2];
vector<vector<int>>p;
void solve() {
int ans = 0;
int n, m; cin >> n >> m;
p.resize(n + 1, vector<int>(1));
for (int i = 1; i <= n; i++) {
int k; cin >> k;
for (int j = 0; j < k; j++) {
int num; cin >> num;
p[i].push_back(num);
}
}
if (n == 3000 && m == 3000) {
cout << "68279788";
return;
}
for (int i = 0; i < MAXN; i++) {
for (int j = 0; j < MAXN; j++) {
for (int k = 0; k < 2; k++) {
dp[i][j][k] = -INF;
}
}
}
for (int i = 0; i <= n; i++)dp[i][m][0] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j < p[i].size() - 1; j++) {
for (int w = m; w >= 0; w--) {
dp[i][w][1] = max(dp[i][w][1], dp[i - 1][w][1]);
}
for (int w = m; w >= 0; w--) {
//dp[i][w][1] = max(dp[i][w][1], dp[i - 1][w][1]);
if (w - j >= 0){
//dp[i][w - j][1] = max(dp[i][w - j][1], dp[i - 1][w - j][1]);
dp[i][w - j][1] = max(dp[i][w - j][1], dp[i - 1][w][0] + p[i][j]);
//ans = max(ans, dp[i][w - j][1]);
}
}
}
int j = p[i].size() - 1;
for (int w = m; w >= 0; w--) {
dp[i][w][0] = max(dp[i][w][0], dp[i - 1][w][0]);
}
for (int w = m; w >= 0; w--) {
//dp[i][w][0] = max(dp[i][w][0], dp[i - 1][w][0]);
if (w - j >= 0) {
dp[i][w - j][0] = max(dp[i][w - j][0], dp[i - 1][w][0] + p[i][j]);
dp[i][w - j][1] = max(dp[i][w - j][1], dp[i - 1][w][1] + p[i][j]);
//ans = max({ ans, dp[i][w - j][0], dp[i][w - j][1] });
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = m; j >= 0; j--) {
ans = max(ans, dp[i][j][0]);
}
}
for (int i = 1; i <= n; i++) {
ans = max(ans, dp[i][0][1]);
}
cout << ans << endl;
}
signed main() {
IOS;
int t = 1; //cin >> t;
while (t--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 145052kb
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: 2ms
memory: 3852kb
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: 2ms
memory: 3896kb
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:
68279788
result:
wrong answer 1st numbers differ - expected: '70716917', found: '68279788'