Submission #751066

#TimeUsernameProblemLanguageResultExecution timeMemory
751066KN200711Detecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms212 KiB
#include "molecules.h" # include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int ans = 0; sort(w.begin(), w.end()); vector<int> sp; sp.clear(); for(int k=0;k<w.size();k++) { if(ans + w[k] <= u) { ans += w[k]; sp.push_back(k); } } if(ans >= l) return sp; int V1 = sp.size() - 1, W = w.size() - 1; while(ans < l && V1 >= 0 && W >= 0) { if(ans + w[W] - w[sp[V1]] <= u) { ans += w[W] - w[sp[V1]]; sp[V1] = W; } else { int G = upper_bound(w.begin(), w.end(), u + sp[V1] - ans) - w.begin(); G--; ans += w[G] - w[sp[V1]]; sp[V1] = G; } V1--; W--; } if(ans >= l) return sp; sp.clear(); return sp; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:10:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for(int k=0;k<w.size();k++) {
      |              ~^~~~~~~~~
#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...