QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#621012 | #5303. No Bug No Game | sazhi | WA | 64ms | 145388kb | C++20 | 2.0kb | 2024-10-08 00:02:48 | 2024-10-08 00:02:48 |
Judging History
answer
// author: jieda
// file: cpp
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
# define fi first
# define se second
# define all(x) x.begin(),x.end()
# define stst stringstream
# define pb push_back
# define pf push_front
# define pp push
# define lowbit(x) (x)&(-x)
# define fa(i,op,n) for (int i = op; i <= n; i++)
# define fb(j,op,n) for (ll j = op; j >= n; j--)
# define fg(i,op,n) for (ll i = op; i != n; i = ne[i])
int dx[4] = {-1,0,1,0},dy[4] = {0,1,0,-1};
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const ll N = 3e3+10,INF = 0x3f3f3f3f,mod = 1e9+7;
const ll MOD = 212370440130137957ll;//hash(hight)
const int base = 131;
const double eps = 1e-3;
const int seed=10086,mo=1e6+7; //hash(lower)
int prime = 233317;
ll dp[2][N][N];
void solve(){
int n,k;cin>>n>>k;
vector<vector<int>> w(n+1,vector<int>(15));
vector<int> p(n+1),pre(n+1);
fa(i,1,n) {
cin>>p[i];
pre[i] = pre[i-1]+p[i];
fa(j,1,p[i]) cin>>w[i][j];
}
if(pre[n]<k){
ll res = 0;
for(int i = 1;i<=n;i++){
res += w[i][p[i]];
}
cout<<res<<'\n';
return ;
}
for(int i = 0;i<=1;i++){
for(int j = 0;j<=n;j++){
for(int p = 0;p<=k;p++){
dp[i][j][p] = -INF;
}
}
}
dp[0][0][0] = dp[1][n+1][0] = 0;
for(int i = 1;i<=n;i++){
for(int j = k;j>=p[i];j--){
dp[0][i][j] = max(dp[0][i-1][j-p[i]]+w[i][p[i]],dp[0][i-1][j]);
}
}
for(int i = n;i>=1;i--){
for(int j= k;j>=p[i];j--){
dp[1][i][j] = max(dp[1][i+1][j-p[i]]+w[i][p[i]],dp[1][i+1][j]);
}
}
ll ans = 0;
for(int i= 1;i<=n;i++){
for(int j = 0;j<=p[i]&&j<=k;j++){
for(int p = 0;p<=pre[i]&&p<=k;p++){
ans = max(ans,w[i][j]+dp[0][i-1][p]+dp[1][i+1][k-p-j]);
}
}
}
cout<<ans<<'\n';
}
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int t = 1;
//cin>>t;
while(t--){
solve();
}
return 0;
}
/*
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5672kb
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: 64ms
memory: 145388kb
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:
99701289
result:
wrong answer 1st numbers differ - expected: '68279788', found: '99701289'