QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#876557#2325. CornspanzyTL 0ms3968kbC++20504b2025-01-31 00:00:082025-01-31 00:00:08

Judging History

This is the latest submission verdict.

  • [2025-01-31 00:00:08]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 3968kb
  • [2025-01-31 00:00:08]
  • Submitted

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;
}

详细

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...

output:


result: