답안 #239254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
239254 2020-06-15T01:57:15 Z urd05 Detecting Molecules (IOI16_molecules) C++14
9 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

bool dp[101][1001];

vector<int> find_subset(int l, int u,vector<int> w) {
    dp[0][0]=true;
    for(int i=0;i<w.size();i++) {
        int ind=i+1;
        for(int j=0;j<=u-w[i];j++) {
            dp[ind][j+w[i]]|=dp[ind-1][j];
            dp[ind][j]|=dp[ind-1][j];
        }
    }
    int n=w.size();
    int pos=-1;
    for(int i=l;i<=u;i++) {
        if (dp[n][i]) {
            pos=i;
        }
    }
    if (pos==-1) {
        vector<int> emp;
        return emp;
    }
    vector<int> ret;
    int sum=pos;
    for(int i=n-1;i>=0;i--) {
        if (sum>=w[i]&&dp[i][sum-w[i]]) {
            ret.push_back(i);
            sum-=w[i];
        }
    }
    return ret;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.size();i++) {
                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 256 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Correct 4 ms 384 KB OK (n = 2, answer = YES)
5 Correct 4 ms 384 KB OK (n = 2, answer = YES)
6 Correct 5 ms 256 KB OK (n = 3, answer = YES)
7 Correct 5 ms 384 KB OK (n = 3, answer = YES)
8 Correct 4 ms 384 KB OK (n = 3, answer = YES)
9 Correct 4 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 384 KB OK (n = 3, answer = YES)
13 Correct 4 ms 384 KB OK (n = 3, answer = NO)
14 Correct 4 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 384 KB OK (n = 3, answer = YES)
16 Correct 4 ms 256 KB OK (n = 3, answer = NO)
17 Correct 4 ms 256 KB OK (n = 3, answer = NO)
18 Correct 5 ms 384 KB OK (n = 100, answer = NO)
19 Correct 5 ms 384 KB OK (n = 100, answer = YES)
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB OK (n = 12, answer = YES)
2 Correct 4 ms 384 KB OK (n = 12, answer = YES)
3 Correct 4 ms 384 KB OK (n = 12, answer = NO)
4 Correct 4 ms 384 KB OK (n = 12, answer = NO)
5 Incorrect 5 ms 384 KB Contestant can not find answer, jury can
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 256 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Correct 4 ms 384 KB OK (n = 2, answer = YES)
5 Correct 4 ms 384 KB OK (n = 2, answer = YES)
6 Correct 5 ms 256 KB OK (n = 3, answer = YES)
7 Correct 5 ms 384 KB OK (n = 3, answer = YES)
8 Correct 4 ms 384 KB OK (n = 3, answer = YES)
9 Correct 4 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 384 KB OK (n = 3, answer = YES)
13 Correct 4 ms 384 KB OK (n = 3, answer = NO)
14 Correct 4 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 384 KB OK (n = 3, answer = YES)
16 Correct 4 ms 256 KB OK (n = 3, answer = NO)
17 Correct 4 ms 256 KB OK (n = 3, answer = NO)
18 Correct 5 ms 384 KB OK (n = 100, answer = NO)
19 Correct 5 ms 384 KB OK (n = 100, answer = YES)
20 Correct 4 ms 256 KB OK (n = 12, answer = YES)
21 Correct 4 ms 384 KB OK (n = 12, answer = YES)
22 Correct 4 ms 384 KB OK (n = 12, answer = NO)
23 Correct 4 ms 384 KB OK (n = 12, answer = NO)
24 Incorrect 5 ms 384 KB Contestant can not find answer, jury can
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 256 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Correct 4 ms 384 KB OK (n = 2, answer = YES)
5 Correct 4 ms 384 KB OK (n = 2, answer = YES)
6 Correct 5 ms 256 KB OK (n = 3, answer = YES)
7 Correct 5 ms 384 KB OK (n = 3, answer = YES)
8 Correct 4 ms 384 KB OK (n = 3, answer = YES)
9 Correct 4 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 384 KB OK (n = 3, answer = YES)
13 Correct 4 ms 384 KB OK (n = 3, answer = NO)
14 Correct 4 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 384 KB OK (n = 3, answer = YES)
16 Correct 4 ms 256 KB OK (n = 3, answer = NO)
17 Correct 4 ms 256 KB OK (n = 3, answer = NO)
18 Correct 5 ms 384 KB OK (n = 100, answer = NO)
19 Correct 5 ms 384 KB OK (n = 100, answer = YES)
20 Correct 4 ms 256 KB OK (n = 12, answer = YES)
21 Correct 4 ms 384 KB OK (n = 12, answer = YES)
22 Correct 4 ms 384 KB OK (n = 12, answer = NO)
23 Correct 4 ms 384 KB OK (n = 12, answer = NO)
24 Incorrect 5 ms 384 KB Contestant can not find answer, jury can
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 256 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Correct 4 ms 384 KB OK (n = 2, answer = YES)
5 Correct 4 ms 384 KB OK (n = 2, answer = YES)
6 Correct 5 ms 256 KB OK (n = 3, answer = YES)
7 Correct 5 ms 384 KB OK (n = 3, answer = YES)
8 Correct 4 ms 384 KB OK (n = 3, answer = YES)
9 Correct 4 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 384 KB OK (n = 3, answer = YES)
13 Correct 4 ms 384 KB OK (n = 3, answer = NO)
14 Correct 4 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 384 KB OK (n = 3, answer = YES)
16 Correct 4 ms 256 KB OK (n = 3, answer = NO)
17 Correct 4 ms 256 KB OK (n = 3, answer = NO)
18 Correct 5 ms 384 KB OK (n = 100, answer = NO)
19 Correct 5 ms 384 KB OK (n = 100, answer = YES)
20 Correct 4 ms 256 KB OK (n = 12, answer = YES)
21 Correct 4 ms 384 KB OK (n = 12, answer = YES)
22 Correct 4 ms 384 KB OK (n = 12, answer = NO)
23 Correct 4 ms 384 KB OK (n = 12, answer = NO)
24 Incorrect 5 ms 384 KB Contestant can not find answer, jury can
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 256 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Correct 4 ms 384 KB OK (n = 2, answer = YES)
5 Correct 4 ms 384 KB OK (n = 2, answer = YES)
6 Correct 5 ms 256 KB OK (n = 3, answer = YES)
7 Correct 5 ms 384 KB OK (n = 3, answer = YES)
8 Correct 4 ms 384 KB OK (n = 3, answer = YES)
9 Correct 4 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 5 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 384 KB OK (n = 3, answer = YES)
13 Correct 4 ms 384 KB OK (n = 3, answer = NO)
14 Correct 4 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 384 KB OK (n = 3, answer = YES)
16 Correct 4 ms 256 KB OK (n = 3, answer = NO)
17 Correct 4 ms 256 KB OK (n = 3, answer = NO)
18 Correct 5 ms 384 KB OK (n = 100, answer = NO)
19 Correct 5 ms 384 KB OK (n = 100, answer = YES)
20 Correct 4 ms 256 KB OK (n = 12, answer = YES)
21 Correct 4 ms 384 KB OK (n = 12, answer = YES)
22 Correct 4 ms 384 KB OK (n = 12, answer = NO)
23 Correct 4 ms 384 KB OK (n = 12, answer = NO)
24 Incorrect 5 ms 384 KB Contestant can not find answer, jury can
25 Halted 0 ms 0 KB -