Submission #997112

#TimeUsernameProblemLanguageResultExecution timeMemory
997112codefoxDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define pii pair<int, int> vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pii> nums; for (int i = 0; i < n; i++) nums.push_back({w[i], i}); sort(nums.begin(), nums.end()); int lefts=n, rights=n; long long sum = 0; while (sum <= u) { left--; sum += nums[lefts].first; } sum -= nums[lefts].first; lefts++; while (sum < l) { rights--; sum -= nums[rights].first; lefts--; sum += nums[lefts].first; } if (sum >= l) { vector<int> ans(rights-lefts); for (int i = lefts; i < rights; i++) { ans[i-lefts] = nums[i].second; } return ans; } else { vector<int> ans(0); return ans; } }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:17:3: warning: ISO C++ forbids decrementing a pointer of type 'std::ios_base& (*)(std::ios_base&)' [-Wpointer-arith]
   17 |   left--;
      |   ^~~~
molecules.cpp:17:3: error: lvalue required as decrement operand