QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#728818 | #5303. No Bug No Game | Fluoresce | WA | 34ms | 74388kb | C++20 | 1.7kb | 2024-11-09 16:00:13 | 2024-11-09 16:00:15 |
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;
for(int i=1;i<=n;++i){
cin>>np[i][0];
for(int j=1;j<=np[i][0];++j)cin>>np[i][j];
}
for(int i=1;i<=n;++i){
p=np[i][0];
w=np[i][p];
for(int j=1;j<=k;++j){
if(p>=j)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(p>=j)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;
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: 100
Accepted
time: 0ms
memory: 3596kb
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: 34ms
memory: 74388kb
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:
199949
result:
wrong answer 1st numbers differ - expected: '68279788', found: '199949'