Submission #388552

#TimeUsernameProblemLanguageResultExecution timeMemory
388552ParsaAlizadehDetecting Molecules (IOI16_molecules)C++17
10 / 100
1 ms208 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int r, vector<int> w) { vector<int> ind(w.size()); iota(begin(ind), end(ind), 0); sort(begin(ind), end(ind), [&] (int i, int j) { return w[i] < w[j]; }); long long cur = 0; int ptr = 0; for (int i = 0; i < w.size(); i++) { cur += w[ind[i]]; while (ptr < i && cur > r) cur -= w[ind[ptr++]]; if (cur >= l) return vector<int>(begin(ind) + ptr, begin(ind) + i + 1); } return vector<int>(0); }

Compilation message (stderr)

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