QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#275515 | #5303. No Bug No Game | chitoge# | WA | 4ms | 4072kb | C++20 | 1.2kb | 2023-12-04 19:53:18 | 2023-12-04 19:53:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
int n , k;
cin >> n >> k;
vector<vector<int> > mat(n);
vector<ll> value(n);
int mx = 0;
ll sum = 0;
for(auto &it : mat) {
int x;
cin >> x;
mx += x;
it.resize(x);
for(auto &v : it) cin >> v , sum += v;
}
for(int i = 0 ; i < n ; ++i) {
ll s = 0;
for(auto it : mat[i]) s += it;
value[i] = s;
}
vector<ll> dp1(k + 1) , dp2;
for(int i = 0 ; i < n ; ++i) {
if(i == n - 1) dp2 = dp1;
int v = mat[i].size();
ll w = value[i];
for(int j = k ; j >= v ; --j) {
dp1[j] = max(dp1[j] , dp1[j - v] + w);
}
}
int w = 0;
for(int i = k ; i >= 0 ; --i) {
if(i != 0) {
if(dp1[i] != dp1[i - 1]) {
w = i;
break;
}
}
}
ll ans = dp1[k];
if(sum == ans) cout << ans << '\n';
else {
cout << ans + k - w << '\n';
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
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: 4ms
memory: 4072kb
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:
203113802
result:
wrong answer 1st numbers differ - expected: '68279788', found: '203113802'