QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#621689 | #5303. No Bug No Game | Albert711 | WA | 32ms | 4252kb | C++20 | 1.2kb | 2024-10-08 16:14:25 | 2024-10-08 16:14:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int N=2e5+5;
#define ll long long
#define int long long
int dp[3005][2];
int len[3005];
int a[3005][20];
void abt(){
int n,k;
cin>>n>>k;
memset(dp,-0x3f,sizeof(dp));
int sum=0;
for(int i=1;i<=n;i++){
cin>>len[i];
sum+=len[i];
for(int j=1;j<=len[i];j++){
cin>>a[i][j];
}
}
dp[0][0]=0;
for(int i=1;i<=n;i++){
for(int j=k;j>=1;j--){
if(j>=len[i]){
dp[j][0]=max(dp[j][0],dp[j-len[i]][0]+a[i][len[i]]);
dp[j][1]=max(dp[j][1],dp[j-len[i]][1]+a[i][len[i]]);
}
}
for(int id=1;id<=len[i]-1;id++){
for(int j=k;j>=1;j--){
if(j>=id) dp[j][1]=max(dp[j][1],dp[j-id][0]+a[i][id]);
}
}
}
if(sum<k){
cout<<dp[sum][0]<<'\n';
// cout<<dp[sum][1]<<'\n';
}else{
cout<<max(dp[k][1],dp[k][0])<<'\n';
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int T=1;
// cin>>T;
while(T--) abt();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3676kb
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: 31ms
memory: 4252kb
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: 32ms
memory: 4120kb
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:
70716942
result:
wrong answer 1st numbers differ - expected: '70716917', found: '70716942'