Submission #754033

#TimeUsernameProblemLanguageResultExecution timeMemory
754033AndreyDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms304 KiB
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
    vector<int> ans(0);
    int a = 0;
    vector<pair<int,int>> haha(0);
    for(int i = 0; i < w.size(); i++) {
        haha.push_back({w[i],i});
    }
    sort(haha.begin(),haha.end());
    for(int i = w.size()-1; i >= 0; i--) {
        if(a+haha[i].first <= u) {
            a+=haha[i].first;
            ans.push_back(haha[i].second);
        }
    }
    if(a >= l) {
        sort(ans.begin(),ans.end());
    }
    else {
        ans.clear();
    }
    return ans;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     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...