Submission #413936

# Submission time Handle Problem Language Result Execution time Memory
413936 2021-05-29T17:43:52 Z Dakto Detecting Molecules (IOI16_molecules) C++17
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
#include "molecules.h"

using namespace std;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    vector<pair<int,int>> v;
    for(int i=0; i<w.size(); i++){
        v.push_back({w[i],i});
    }
    sort(v.begin(),v.end());
    auto f=v[0];
    v.erase(v.begin());
    vector<int> res;
    int s=0;

    while(!v.empty()){
        if(s>=l) break;
        s+=end(v)->first;
        res.push_back(v.back().second);
        v.erase(v.end()-1);
        if(s>=l) break;
        if(s+f.first>=l){
            s+=f.first;
            res.push_back(f.second);
        }
    }
    if(s>=l && s<=u) return res;
    else return vector<int>(0);
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i=0; i<w.size(); i++){
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB OK (n = 1, answer = NO)
2 Correct 1 ms 204 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 204 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB OK (n = 1, answer = NO)
2 Correct 1 ms 204 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 204 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB OK (n = 1, answer = NO)
2 Correct 1 ms 204 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 204 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB OK (n = 1, answer = NO)
2 Correct 1 ms 204 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 204 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB OK (n = 1, answer = NO)
2 Correct 1 ms 204 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 204 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -