QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#750188 | #5303. No Bug No Game | HaijieTan | RE | 0ms | 3552kb | C++23 | 3.1kb | 2024-11-15 13:20:18 | 2024-11-15 13:20:20 |
Judging History
answer
#include<iostream>
#include<vector>
#include<bitset>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<numeric>//iota -- iota(all(a), x) a从头到尾从x开始递增
#include<cstring>
#include<ctime>
#include<array>
#include<list>
#include<random>
#include<tuple>
#include<deque>
#include<map>
#include<stack>
#include<set>
using namespace std;
template <typename Dtype>
unsigned int __builtin_popcount(Dtype u){
u = (u & 0x55555555) + ((u >> 1) & 0x55555555);
u = (u & 0x33333333) + ((u >> 2) & 0x33333333);
u = (u & 0x0F0F0F0F) + ((u >> 4) & 0x0F0F0F0F);
u = (u & 0x00FF00FF) + ((u >> 8) & 0x00FF00FF);
u = (u & 0x0000FFFF) + ((u >> 16) & 0x0000FFFF);
return u;
}//wishchin!!!
#define IOS ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define int long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
#define lowbit(x) (x & (-x))
const int xy[][2] = { 0,1, 0, -1, 1, 0, -1, 0 };
#define mem(a, x) memset(a, x, sizeof a)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<char, char> PCC;
typedef pair<int, char> PIC;
typedef pair<char, int> PCI;
#define x first
#define y second
#define NO cout << "NO\n"
#define YES cout << "YES\n"
inline int read();
const int INF = 1e18, N = 1e4 + 10, MOD = 998244353, M = 1e4 + 10, K = 131;
const double PI = acos(-1.0);
void solve() {
int n, k; cin >> n >> k;
//int dp[3030][3030][2], w[3030][11], p[3030];
vector<vector<vector<int>>>dp(n + 2, vector<vector<int>>(max(k, 12ll), vector<int>(3, -INF)));
vector<vector<int>>w(n + 2, vector<int>(11));
vector<int>p(n + 2);
for (int i = 1; i <= n; i++) {
cin >> p[i];
for (int j = 1; j <= p[i]; j++)cin >> w[i][j];
}
dp[0][0][0] = 0;
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][0] = max(dp[i][j][0], dp[i - 1][j - p[i]][0] + w[i][p[i]]);
dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j - p[i]][1] + w[i][p[i]]);
}
//cout << i << ' ' << j << endl;
for (int t = 1; t <= p[i]; t++) {
if (j >= t)
dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j - t][0] + w[i][t]);
}
}
}
int ret = 0;
for(int i= 1; i <= n; i++)
for (int j = 0; j <= k; j++) {
ret = max(ret, dp[i][j][0]);
if (j == k)ret = max(ret, dp[i][j][1]);
}
cout << ret << endl;
}
signed main() {
IOS;
int _ = 1;
//cin >> _;
while (_--)solve();
return 0;
}
inline int read()
{
int x = 0, f = 1; char ch = getchar();
while (ch < '0' || ch>'9') { if (ch == '-') f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
return x * f;
}
/* /\_/\
* (= ._.)
* / > \>
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
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...