Submission #505140

#TimeUsernameProblemLanguageResultExecution timeMemory
505140sliviuDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int r, vector<int> v) { int n = v.size(); long long s = 0; vector<int> p(n), ans; iota(p.begin(), p.end(), 0); sort(p.begin(), p.end(), [&](int i, int j) {return v[i] < v[j]; }); for (int i = 0, j = -1; i < n; ++i) { while (j + 1 < n && s < l) s += v[p[++j]]; if (l <= s && s <= r) { for (int k = i; k <= j; ++k) ans.emplace_back(p[k]); return ans; } if (i <= j) s -= v[p[i]]; } }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:17: warning: control reaches end of non-void function [-Wreturn-type]
    9 |  vector<int> p(n), ans;
      |                 ^
#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...