Submission #758971

#TimeUsernameProblemLanguageResultExecution timeMemory
758971raysh07Detecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms300 KiB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    int sum = 0;
    
    for (auto x : w) sum += x;
    
    vector <pair<int, int>> a;
    for (int i = 0; i < w.size(); i++){
        a.push_back(make_pair(w[i], i));
    }
    
    sort(a.begin(), a.end(), greater<pair<int, int>>());
    
    if (sum < l)
    return std::vector<int>(0);
    
    vector <int> v;
    for (auto x : a){
        if (x.first <= u){
            u -= x.first;
            l -= x.first;
            v.push_back(x.second);
        }
    }
    
    return v;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int i = 0; i < w.size(); i++){
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...