Submission #170127

#TimeUsernameProblemLanguageResultExecution timeMemory
170127buttercrabDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h" using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pair<int, int>> v; for (int i = 0; i < n; i++) { v.emplace_back(w[i], i); } sort(v.begin(), v.end()); int s = 0, h = 0, t = 0; while (t < n) { while (t < n && s < l) { s += v[t].first; t++; } if (l <= s && s <= u) { vector<int> ans; for (int i = h; i < t; i++) ans.emplace_back(i); return ans; } while (h < t && s >= l) { s -= w[h]; h++; } } return vector<int>(); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:5: error: 'sort' was not declared in this scope
     sort(v.begin(), v.end());
     ^~~~
molecules.cpp:12:5: note: suggested alternative: 'short'
     sort(v.begin(), v.end());
     ^~~~
     short