Submission #107998

# Submission time Handle Problem Language Result Execution time Memory
107998 2019-04-26T18:19:04 Z FiloSanza Detecting Molecules (IOI16_molecules) C++14
0 / 100
3 ms 400 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(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()){
        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 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 384 KB OK (n = 1, answer = NO)
3 Correct 2 ms 384 KB OK (n = 1, answer = YES)
4 Incorrect 2 ms 400 KB sum of weights should be in [100..100] but it is 50
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 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 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 384 KB OK (n = 1, answer = NO)
3 Correct 2 ms 384 KB OK (n = 1, answer = YES)
4 Incorrect 2 ms 400 KB sum of weights should be in [100..100] but it is 50
5 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 384 KB OK (n = 1, answer = NO)
3 Correct 2 ms 384 KB OK (n = 1, answer = YES)
4 Incorrect 2 ms 400 KB sum of weights should be in [100..100] but it is 50
5 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 384 KB OK (n = 1, answer = NO)
3 Correct 2 ms 384 KB OK (n = 1, answer = YES)
4 Incorrect 2 ms 400 KB sum of weights should be in [100..100] but it is 50
5 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 384 KB OK (n = 1, answer = NO)
3 Correct 2 ms 384 KB OK (n = 1, answer = YES)
4 Incorrect 2 ms 400 KB sum of weights should be in [100..100] but it is 50
5 Halted 0 ms 0 KB -