QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#729023 | #5303. No Bug No Game | Fluoresce | WA | 3ms | 74484kb | C++20 | 1.9kb | 2024-11-09 16:22:36 | 2024-11-09 16:22:36 |
Judging History
answer
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define debug(a) cout<<a<<'\n'
#define Pll pair<ll,ll>
#define PII pair<int,int>
#define ft first
#define sd second
#define vec vector
#define pushk push_back
#define ump unordered_map
#define pl p<<1
#define pr p<<1|1
using namespace std;
const int N = 3e3 + 10, M = 2e6 + 10, mod = 1e9+7;
const ll inf = 1e18;
const ld eps = 1e-13;
int mov[4][2] = { {0,1},{1,0},{-1,0},{0,-1} }, dx, dy, _ = 1, __ = 1;
void bout(bool f) {
if (f)cout << "YES\n";
else cout << "NO\n";
}
ll n,m,k;
int pre[N][N],suf[N][N],np[N][15];
void ini() {
}
void solve() {
cin>>n>>k;
int x,y,z,w,v,p,sp=0;
for(int i=1;i<=n;++i){
cin>>np[i][0];
sp+=np[i][0];
for(int j=1;j<=np[i][0];++j)cin>>np[i][j];
}
memset(pre,0xcf,sizeof pre);
memset(suf,0x3f,sizeof suf);
pre[0][0]=suf[n+1][0]=0;
for(int i=1;i<=n;++i){
p=np[i][0];
w=np[i][p];
for(int j=1;j<=k;++j){
if(j>=p)pre[i][j]=max(pre[i-1][j],pre[i-1][j-p]+w);
else pre[i][j]=pre[i-1][j];
}
}
for(int i=n;i>=1;--i){
p=np[i][0];
w=np[i][p];
for(int j=1;j<=k;++j){
if(j>=p)suf[i][j]=max(suf[i+1][j],suf[i+1][j-p]+w);
else suf[i][j]=suf[i+1][j];
}
}
int ans=0;
if(sp<=k)ans=pre[n][sp];
for(int i=1;i<=n;++i){
p=np[i][0];
for(int V=k-p+1;V<k;++V){
w=np[i][k-V];
for(int j=0;j<=V;++j){
ans=max(ans,pre[i-1][j]+suf[i+1][V-j]+w);
}
}
}
cout<<ans;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
streambuf *cinbp=cin.rdbuf(),*coutbp=cout.rdbuf();
ifstream fin("in.txt");
ofstream fout("out.txt");
cin.rdbuf(fin.rdbuf());
cout.rdbuf(fout.rdbuf());
#endif
//cin >> _;
__ = _;
ini();
while (_--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 74484kb
input:
4 5 2 1 3 2 1 1 2 3 1 2 1 3
output:
1061109574
result:
wrong answer 1st numbers differ - expected: '9', found: '1061109574'