QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#876557 | #2325. Corns | panzy | TL | 0ms | 3968kb | C++20 | 504b | 2025-01-31 00:00:08 | 2025-01-31 00:00:08 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <vector>
int main() {
int n,w;
std::cin >> n >> w;
std::vector<int>dp(2e5+7);
dp[0] = 1;
for(int i = 1; i <= n; i ++){
int x;
std::cin >> x;
for(int j = w; j >= 0; j --){
if(j>=x)dp[j] = std::max(dp[j],dp[j-x]);
}
}
for(int i = w; i >= 0; i --){
if(dp[i]){
std::cout << i << std::endl;
break;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3968kb
input:
3 10 1 1 11
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
4 10 3 5 3 4
output:
10
result:
ok single line: '10'
Test #3:
score: -100
Time Limit Exceeded
input:
30669 199323 7 6 7 7 7 7 6 7 7 7 7 6 7 6 6 7 7 7 7 6 6 7 7 7 6 6 6 7 7 7 6 6 7 7 6 6 7 6 7 6 7 6 6 6 6 6 7 7 7 6 6 6 6 6 6 6 7 7 6 6 7 6 6 7 6 6 6 6 6 7 7 7 7 6 7 7 6 6 7 6 7 6 6 6 6 7 6 7 6 7 6 7 6 7 7 7 7 6 7 7 6 6 6 6 7 6 7 7 7 7 6 7 7 7 7 7 7 6 6 6 7 7 7 6 7 7 7 7 6 7 7 6 6 6 6 7 6 7 7 7 6 6 7 7...