QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#625535 | #5303. No Bug No Game | PonyHex | WA | 28ms | 74532kb | C++20 | 2.1kb | 2024-10-09 19:39:23 | 2024-10-09 19:39:23 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define double long double
//#define int long long
#define lc u<<1
#define rc u<<1|1
#define endl "\n"
#define X first
#define Y second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> PII;
const ll N = 3e3 + 5;
const ll maxm = 2e18;
const ll mod = 1e9 + 7;
ll exgcd(ll a, ll b, ll& x, ll& y);
ll p[N];
ll a[N][15];
ll n, k;
ll dp[N][N];
void solve() {
cin >> n >> k;
ll ans = 0;
for (int i = 1; i <= n; i++) {
cin >> p[i]; a[i][0] = 0;
for (int j = 1; j <= p[i]; j++) {
cin >> a[i][j]; a[i][j] += a[i][j - 1];
}
}
for (int i = 1; i <= n; i++) {//枚举物品
for (int j = 0; j < k; j++) {//枚举过去的状态,
//更新新的状态,但是新的状态不能被当前状态继承到
//我们应该开二维,9e6,好像开不出来,唉开出来,mle再改滑动数组
dp[i][j] = max(dp[i][j], dp[i - 1][j]);
if (j + p[i] <= k) {
dp[i][j + p[i]] = max(dp[i][j + p[i]], dp[i - 1][j] + a[i][p[i]]);
}
else {
dp[i][k] = max(dp[i][k], dp[i - 1][j] + a[i][k-j]);
}
if (j != 0)dp[i][j] = max(dp[i][j], dp[i][j - 1]);
}
dp[i][k] = max(dp[i][k], dp[i][k-1]);
}
cout << dp[n][k] << endl;
return;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
ll t = 1;//cin >> t;
while (t--)solve();
return 0;
}
/*PonyHex*/
ll exgcd(ll a, ll b, ll& x, ll& y) {
if (b == 0) {
x = 1; y = 0;
return a;
}
ll g = exgcd(b, a % b, x, y);
ll temp = x;
x = y;
y = temp - (a / b) * y;
return g;
}
/*
ll ksm(ll a, ll b) {
ll base = a;
ll ans = 1;
while (b) {
if (b & 1)ans *= base;
base *= base;
b >>= 1;
}
return ans;
}*/
/*
ll gcd(ll a, ll b) {
return b ? gcd(b, a % b) : a;
}*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3672kb
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: 28ms
memory: 74532kb
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:
203109421
result:
wrong answer 1st numbers differ - expected: '68279788', found: '203109421'