Submission #299153

#TimeUsernameProblemLanguageResultExecution timeMemory
299153azategaDetecting Molecules (IOI16_molecules)C++11
Compilation error
0 ms0 KiB
#include "molecules.h" #include <vector> #include <algorithm> #include <iostream> using namespace std; #define ll long long vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<ll, int>> new_w; vector<int> bl; int n = w.size(); ll tot_sum = 0; for(int i = 0; i < n; i++){ tot_sum += w[i]; new_w.push_back({w[i], i}); } sort(new_w.begin(), new_w.end()); ll currsum = 0; int tot_sum_idx = 0; for(int i = 0; i < n; i++){ currsum += new_w[i].first; if(currsum > u) break; while(tot_sum_idx <= i) tot_sum -= new_w[tot_sum_idx++].first; while(tot_sum + currsum > u) tot_sum -= new_w[tot_sum_idx++].first; if(tot_sum + currsum >= l){ vector<int> res; for(int x = 0; x <= i; x++) res.push_back(new_w[x].second); for(int x = tot_sum_idx; x < n; x++) res.push_back(new_w[x].second); return res; } } return bl; } int main(){ int n, l, u; vector<int> niz; cin >> n >> l >> u; niz.resize(n); for(int i = 0; i < n; i++) cin >> niz[i]; vector<int> rs = find_subset(l, u, niz); for(int i = 0; i < rs.size(); i++) cout << rs[i] << endl; }

Compilation message (stderr)

molecules.cpp: In function 'int main()':
molecules.cpp:59:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |  for(int i = 0; i < rs.size(); i++)
      |                 ~~^~~~~~~~~~~
/tmp/ccCRBipG.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cckvCkEe.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status