Submission #107999

# Submission time Handle Problem Language Result Execution time Memory
107999 2019-04-26T18:23:29 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(int i=0; i<w.size(); i++)if(el.count(w[i])){
        el.erase(el.find(w[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()){
        cout << sum << "\n";
        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);
}

Compilation message

molecules.cpp: In function 'std::vector<int> build(std::multiset<int>&, const std::vector<int>&)':
molecules.cpp:8:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<w.size(); i++)if(el.count(w[i])){
                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Secret is incorrect!
2 Halted 0 ms 0 KB -