Submission #61983

#TimeUsernameProblemLanguageResultExecution timeMemory
61983fallingstarDetecting Molecules (IOI16_molecules)C++14
100 / 100
98 ms3224 KiB
#include "molecules.h" #include <algorithm> using namespace std; vector<int> find_subset(int low, int upp, vector<int> w) { int n = w.size(); vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = i; sort(a.begin(), a.end(), [&](int x, int y) { return w[x] < w[y]; }); unsigned int sum = 0; for (int i = 0, j = 0; i < n; ++i) { sum += w[a[i]]; if (sum > upp) sum -= w[a[j++]]; if (j > i) break; if (low <= sum && sum <= upp) return vector<int>(a.begin() + j, a.begin() + i + 1); } return vector<int>(); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:16:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (sum > upp) sum -= w[a[j++]];
             ~~~~^~~~~
molecules.cpp:18:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (low <= sum && sum <= upp) return vector<int>(a.begin() + j, a.begin() + i + 1);
             ~~~~^~~~~~
molecules.cpp:18:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (low <= sum && sum <= upp) return vector<int>(a.begin() + j, a.begin() + i + 1);
                           ~~~~^~~~~~
#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...