Submission #612029

#TimeUsernameProblemLanguageResultExecution timeMemory
612029boris_mihovDetecting Molecules (IOI16_molecules)C++14
100 / 100
63 ms4764 KiB
#include "molecules.h" #include <algorithm> #include <numeric> typedef long long llong; const int MAXN = 200000 + 10; int perm[MAXN], n; std::vector <int> find_subset(int l, int u, std::vector <int> w) { n = w.size(); std::iota(perm+1, perm+1+n, 0); std::sort(perm+1, perm+1+n, [&](int x, int y) { return w[x] < w[y]; }); std::sort(w.begin(), w.end()); int lp = 1; llong sum = 0; for (int rp = 1 ; rp <= w.size() ; ++rp) { sum += w[rp - 1]; while (sum > u) sum -= w[lp++ - 1]; if (l <= sum && sum <= u) { std::vector <int> ans; for (int j = lp ; j <= rp ; ++j) { ans.push_back(perm[j]); } return ans; } } return {}; }

Compilation message (stderr)

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