Submission #138814

# Submission time Handle Problem Language Result Execution time Memory
138814 2019-07-30T11:16:45 Z RiscadoA Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 376 KB
#include "molecules.h"
#include <bits/stdc++.h>

const int MAX_N = 200000;

std::vector<int> find_subset(int l, int u, std::vector<int> wo)
{
        std::vector<int> ret;
        
        std::vector<std::pair<int, int>> w;
        for (int i = 0; i < wo.size(); ++i)
                w.push_back(std::make_pair(wo[i], i));

        std::sort(w.begin(), w.end());
        int i, sum;
        for (i = 0, sum = 0; i < MAX_N; ++i) {
                sum += w[i].first;
                if (sum >= l) {
                        ++i;
                        break;
                }
        }
        if (sum < l)
                return {};
        else if (sum <= u)
                for (int j = 0; j < i; ++j)
                        ret.push_back(j + 1);
        else {
                int j;
                for (j = 0; j < i; ++j) {
                        sum -= w[j].first;
                        if (sum <= u) {
                                ++j;
                                break;
                        }
                }
                
                if (sum < l)
                        return {};
                for (; j < i; ++j)
                        ret.push_back(w[j].second);

        }
        return ret;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < wo.size(); ++i)
                         ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 252 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 252 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 252 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 252 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 252 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -