Submission #107997

# Submission time Handle Problem Language Result Execution time Memory
107997 2019-04-26T18:16:50 Z FiloSanza Detecting Molecules (IOI16_molecules) C++14
0 / 100
3 ms 384 KB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> build(multiset<int>& el, const vector<int>& w){
    vector<int> sol;
    for(auto i : w)if(el.count(i)){
        el.erase(i);
        sol.push_back(i);
    }
    return sol;
}

vector<int> find_subset(int l, int u, vector<int> w) {
    sort(w.begin(), w.end());
    long long sum = 0;

    multiset<int> el;
    for(auto i : w) sum += 1LL*i, el.insert(i);

    while(!el.empty()){
        if(sum < l) return vector<int>(0);
        if(sum >= l && sum <= u) return build(el, w);
        long long diff = sum - u;
        auto it = el.lower_bound(diff);

        if(it == el.end())
            it = prev(el.end());
        sum -= *it;
        el.erase(it);
    }

    return vector<int>(0);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 3 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 3 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 3 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 3 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 3 ms 384 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 256 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -