Submission #44834

# Submission time Handle Problem Language Result Execution time Memory
44834 2018-04-08T03:35:29 Z RayaBurong25_1 Detecting Molecules (IOI16_molecules) C++17
9 / 100
2 ms 648 KB
#include "molecules.h"
#include <stdio.h>
#include <algorithm>
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());
    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:32: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 248 KB OK (n = 1, answer = NO)
2 Correct 2 ms 364 KB OK (n = 1, answer = NO)
3 Correct 2 ms 440 KB OK (n = 1, answer = YES)
4 Correct 2 ms 440 KB OK (n = 2, answer = YES)
5 Correct 2 ms 440 KB OK (n = 2, answer = YES)
6 Correct 2 ms 544 KB OK (n = 3, answer = YES)
7 Correct 2 ms 544 KB OK (n = 3, answer = YES)
8 Correct 2 ms 544 KB OK (n = 3, answer = YES)
9 Correct 2 ms 544 KB OK (n = 3, answer = YES)
10 Correct 2 ms 572 KB OK (n = 3, answer = YES)
11 Correct 2 ms 572 KB OK (n = 3, answer = YES)
12 Correct 2 ms 572 KB OK (n = 3, answer = YES)
13 Correct 2 ms 572 KB OK (n = 3, answer = NO)
14 Correct 2 ms 572 KB OK (n = 3, answer = YES)
15 Correct 2 ms 572 KB OK (n = 3, answer = YES)
16 Correct 2 ms 572 KB OK (n = 3, answer = NO)
17 Correct 2 ms 648 KB OK (n = 3, answer = NO)
18 Correct 2 ms 648 KB OK (n = 100, answer = NO)
19 Correct 2 ms 648 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 648 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB OK (n = 1, answer = NO)
2 Correct 2 ms 364 KB OK (n = 1, answer = NO)
3 Correct 2 ms 440 KB OK (n = 1, answer = YES)
4 Correct 2 ms 440 KB OK (n = 2, answer = YES)
5 Correct 2 ms 440 KB OK (n = 2, answer = YES)
6 Correct 2 ms 544 KB OK (n = 3, answer = YES)
7 Correct 2 ms 544 KB OK (n = 3, answer = YES)
8 Correct 2 ms 544 KB OK (n = 3, answer = YES)
9 Correct 2 ms 544 KB OK (n = 3, answer = YES)
10 Correct 2 ms 572 KB OK (n = 3, answer = YES)
11 Correct 2 ms 572 KB OK (n = 3, answer = YES)
12 Correct 2 ms 572 KB OK (n = 3, answer = YES)
13 Correct 2 ms 572 KB OK (n = 3, answer = NO)
14 Correct 2 ms 572 KB OK (n = 3, answer = YES)
15 Correct 2 ms 572 KB OK (n = 3, answer = YES)
16 Correct 2 ms 572 KB OK (n = 3, answer = NO)
17 Correct 2 ms 648 KB OK (n = 3, answer = NO)
18 Correct 2 ms 648 KB OK (n = 100, answer = NO)
19 Correct 2 ms 648 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 648 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB OK (n = 1, answer = NO)
2 Correct 2 ms 364 KB OK (n = 1, answer = NO)
3 Correct 2 ms 440 KB OK (n = 1, answer = YES)
4 Correct 2 ms 440 KB OK (n = 2, answer = YES)
5 Correct 2 ms 440 KB OK (n = 2, answer = YES)
6 Correct 2 ms 544 KB OK (n = 3, answer = YES)
7 Correct 2 ms 544 KB OK (n = 3, answer = YES)
8 Correct 2 ms 544 KB OK (n = 3, answer = YES)
9 Correct 2 ms 544 KB OK (n = 3, answer = YES)
10 Correct 2 ms 572 KB OK (n = 3, answer = YES)
11 Correct 2 ms 572 KB OK (n = 3, answer = YES)
12 Correct 2 ms 572 KB OK (n = 3, answer = YES)
13 Correct 2 ms 572 KB OK (n = 3, answer = NO)
14 Correct 2 ms 572 KB OK (n = 3, answer = YES)
15 Correct 2 ms 572 KB OK (n = 3, answer = YES)
16 Correct 2 ms 572 KB OK (n = 3, answer = NO)
17 Correct 2 ms 648 KB OK (n = 3, answer = NO)
18 Correct 2 ms 648 KB OK (n = 100, answer = NO)
19 Correct 2 ms 648 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 648 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB OK (n = 1, answer = NO)
2 Correct 2 ms 364 KB OK (n = 1, answer = NO)
3 Correct 2 ms 440 KB OK (n = 1, answer = YES)
4 Correct 2 ms 440 KB OK (n = 2, answer = YES)
5 Correct 2 ms 440 KB OK (n = 2, answer = YES)
6 Correct 2 ms 544 KB OK (n = 3, answer = YES)
7 Correct 2 ms 544 KB OK (n = 3, answer = YES)
8 Correct 2 ms 544 KB OK (n = 3, answer = YES)
9 Correct 2 ms 544 KB OK (n = 3, answer = YES)
10 Correct 2 ms 572 KB OK (n = 3, answer = YES)
11 Correct 2 ms 572 KB OK (n = 3, answer = YES)
12 Correct 2 ms 572 KB OK (n = 3, answer = YES)
13 Correct 2 ms 572 KB OK (n = 3, answer = NO)
14 Correct 2 ms 572 KB OK (n = 3, answer = YES)
15 Correct 2 ms 572 KB OK (n = 3, answer = YES)
16 Correct 2 ms 572 KB OK (n = 3, answer = NO)
17 Correct 2 ms 648 KB OK (n = 3, answer = NO)
18 Correct 2 ms 648 KB OK (n = 100, answer = NO)
19 Correct 2 ms 648 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 648 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB OK (n = 1, answer = NO)
2 Correct 2 ms 364 KB OK (n = 1, answer = NO)
3 Correct 2 ms 440 KB OK (n = 1, answer = YES)
4 Correct 2 ms 440 KB OK (n = 2, answer = YES)
5 Correct 2 ms 440 KB OK (n = 2, answer = YES)
6 Correct 2 ms 544 KB OK (n = 3, answer = YES)
7 Correct 2 ms 544 KB OK (n = 3, answer = YES)
8 Correct 2 ms 544 KB OK (n = 3, answer = YES)
9 Correct 2 ms 544 KB OK (n = 3, answer = YES)
10 Correct 2 ms 572 KB OK (n = 3, answer = YES)
11 Correct 2 ms 572 KB OK (n = 3, answer = YES)
12 Correct 2 ms 572 KB OK (n = 3, answer = YES)
13 Correct 2 ms 572 KB OK (n = 3, answer = NO)
14 Correct 2 ms 572 KB OK (n = 3, answer = YES)
15 Correct 2 ms 572 KB OK (n = 3, answer = YES)
16 Correct 2 ms 572 KB OK (n = 3, answer = NO)
17 Correct 2 ms 648 KB OK (n = 3, answer = NO)
18 Correct 2 ms 648 KB OK (n = 100, answer = NO)
19 Correct 2 ms 648 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 648 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -