Submission #44836

# Submission time Handle Problem Language Result Execution time Memory
44836 2018-04-08T03:59:04 Z RayaBurong25_1 Detecting Molecules (IOI16_molecules) C++17
9 / 100
2 ms 628 KB
#include "molecules.h"
#include <stdio.h>
#include <algorithm>
int compare(std::pair<int, int> a, std::pair<int, int> b)
{
    return (a.first < b.first || (a.first == b.first && a.second < b.second));
}
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    std::vector<std::pair<int, int> > W;
    std::vector<int> V;
    int n = w.size(), i, j;
    int mn = 0, mx = 0;
    for (i = 0; i < n; i++)
        W.push_back({w[i], i});
    std::sort(W.begin(), W.end(), compare);
    for (i = 0; i < n; i++)
    {
        mn += W[i].first;
        mx += W[n - 1 - i].first;
        // printf("mn %d mx %d\n", mn, mx);
        if ((l <= mx && mx <= u) || (l <= mn && mn <= u))
            break;
    }
    if (i == n)
        return V;
    for (j = 0; j <= i; j++)
        V.push_back(j);
    while (mn < l)
    {
        if (V[i] == n - (j - i))
            i--;
        mn -= W[V[i]].first;
        V[i]++;
        mn += W[V[i]].first;
    }
    for (i = 0; i < V.size(); i++)
        V[i] = W[V[i]].second;
    return V;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:36:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0; i < V.size(); i++)
                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 488 KB OK (n = 1, answer = NO)
3 Correct 2 ms 488 KB OK (n = 1, answer = YES)
4 Correct 2 ms 488 KB OK (n = 2, answer = YES)
5 Correct 2 ms 608 KB OK (n = 2, answer = YES)
6 Correct 2 ms 608 KB OK (n = 3, answer = YES)
7 Correct 2 ms 608 KB OK (n = 3, answer = YES)
8 Correct 2 ms 608 KB OK (n = 3, answer = YES)
9 Correct 2 ms 608 KB OK (n = 3, answer = YES)
10 Correct 2 ms 628 KB OK (n = 3, answer = YES)
11 Correct 2 ms 628 KB OK (n = 3, answer = YES)
12 Correct 2 ms 628 KB OK (n = 3, answer = YES)
13 Correct 2 ms 628 KB OK (n = 3, answer = NO)
14 Correct 2 ms 628 KB OK (n = 3, answer = YES)
15 Correct 2 ms 628 KB OK (n = 3, answer = YES)
16 Correct 2 ms 628 KB OK (n = 3, answer = NO)
17 Correct 2 ms 628 KB OK (n = 3, answer = NO)
18 Correct 2 ms 628 KB OK (n = 100, answer = NO)
19 Correct 2 ms 628 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 628 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 488 KB OK (n = 1, answer = NO)
3 Correct 2 ms 488 KB OK (n = 1, answer = YES)
4 Correct 2 ms 488 KB OK (n = 2, answer = YES)
5 Correct 2 ms 608 KB OK (n = 2, answer = YES)
6 Correct 2 ms 608 KB OK (n = 3, answer = YES)
7 Correct 2 ms 608 KB OK (n = 3, answer = YES)
8 Correct 2 ms 608 KB OK (n = 3, answer = YES)
9 Correct 2 ms 608 KB OK (n = 3, answer = YES)
10 Correct 2 ms 628 KB OK (n = 3, answer = YES)
11 Correct 2 ms 628 KB OK (n = 3, answer = YES)
12 Correct 2 ms 628 KB OK (n = 3, answer = YES)
13 Correct 2 ms 628 KB OK (n = 3, answer = NO)
14 Correct 2 ms 628 KB OK (n = 3, answer = YES)
15 Correct 2 ms 628 KB OK (n = 3, answer = YES)
16 Correct 2 ms 628 KB OK (n = 3, answer = NO)
17 Correct 2 ms 628 KB OK (n = 3, answer = NO)
18 Correct 2 ms 628 KB OK (n = 100, answer = NO)
19 Correct 2 ms 628 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 628 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 488 KB OK (n = 1, answer = NO)
3 Correct 2 ms 488 KB OK (n = 1, answer = YES)
4 Correct 2 ms 488 KB OK (n = 2, answer = YES)
5 Correct 2 ms 608 KB OK (n = 2, answer = YES)
6 Correct 2 ms 608 KB OK (n = 3, answer = YES)
7 Correct 2 ms 608 KB OK (n = 3, answer = YES)
8 Correct 2 ms 608 KB OK (n = 3, answer = YES)
9 Correct 2 ms 608 KB OK (n = 3, answer = YES)
10 Correct 2 ms 628 KB OK (n = 3, answer = YES)
11 Correct 2 ms 628 KB OK (n = 3, answer = YES)
12 Correct 2 ms 628 KB OK (n = 3, answer = YES)
13 Correct 2 ms 628 KB OK (n = 3, answer = NO)
14 Correct 2 ms 628 KB OK (n = 3, answer = YES)
15 Correct 2 ms 628 KB OK (n = 3, answer = YES)
16 Correct 2 ms 628 KB OK (n = 3, answer = NO)
17 Correct 2 ms 628 KB OK (n = 3, answer = NO)
18 Correct 2 ms 628 KB OK (n = 100, answer = NO)
19 Correct 2 ms 628 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 628 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 488 KB OK (n = 1, answer = NO)
3 Correct 2 ms 488 KB OK (n = 1, answer = YES)
4 Correct 2 ms 488 KB OK (n = 2, answer = YES)
5 Correct 2 ms 608 KB OK (n = 2, answer = YES)
6 Correct 2 ms 608 KB OK (n = 3, answer = YES)
7 Correct 2 ms 608 KB OK (n = 3, answer = YES)
8 Correct 2 ms 608 KB OK (n = 3, answer = YES)
9 Correct 2 ms 608 KB OK (n = 3, answer = YES)
10 Correct 2 ms 628 KB OK (n = 3, answer = YES)
11 Correct 2 ms 628 KB OK (n = 3, answer = YES)
12 Correct 2 ms 628 KB OK (n = 3, answer = YES)
13 Correct 2 ms 628 KB OK (n = 3, answer = NO)
14 Correct 2 ms 628 KB OK (n = 3, answer = YES)
15 Correct 2 ms 628 KB OK (n = 3, answer = YES)
16 Correct 2 ms 628 KB OK (n = 3, answer = NO)
17 Correct 2 ms 628 KB OK (n = 3, answer = NO)
18 Correct 2 ms 628 KB OK (n = 100, answer = NO)
19 Correct 2 ms 628 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 628 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 488 KB OK (n = 1, answer = NO)
3 Correct 2 ms 488 KB OK (n = 1, answer = YES)
4 Correct 2 ms 488 KB OK (n = 2, answer = YES)
5 Correct 2 ms 608 KB OK (n = 2, answer = YES)
6 Correct 2 ms 608 KB OK (n = 3, answer = YES)
7 Correct 2 ms 608 KB OK (n = 3, answer = YES)
8 Correct 2 ms 608 KB OK (n = 3, answer = YES)
9 Correct 2 ms 608 KB OK (n = 3, answer = YES)
10 Correct 2 ms 628 KB OK (n = 3, answer = YES)
11 Correct 2 ms 628 KB OK (n = 3, answer = YES)
12 Correct 2 ms 628 KB OK (n = 3, answer = YES)
13 Correct 2 ms 628 KB OK (n = 3, answer = NO)
14 Correct 2 ms 628 KB OK (n = 3, answer = YES)
15 Correct 2 ms 628 KB OK (n = 3, answer = YES)
16 Correct 2 ms 628 KB OK (n = 3, answer = NO)
17 Correct 2 ms 628 KB OK (n = 3, answer = NO)
18 Correct 2 ms 628 KB OK (n = 100, answer = NO)
19 Correct 2 ms 628 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 628 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -