Submission #81770

#TimeUsernameProblemLanguageResultExecution timeMemory
81770AngelKnowsDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h" using namespace std; const int inf=0x3f3f3f3f; std::vector<int> find_subset(int l, int u, std::vector<int> w) { sort(w.begin(),w.end()); vector<int> ans; int L=l,R=u; if (L<=w[0]&&w[0]<=R) { ans.push_back(w[0]); return ans; } else if (w[0]>R) { return vector<int>(0); } else if (w[0]<L) { int t=w.back(); if (L<=t&&t<=R) { ans.push_back(t); return ans; } else if (t<L) { long long sum=0; for (int i=0;i<w.size();i++) { sum+=w[i]; ans.push_back(w[i]); if (L<=sum&&sum<=R) { return ans; } } return vector<int>(0); } } }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:6:2: error: 'sort' was not declared in this scope
  sort(w.begin(),w.end());
  ^~~~
molecules.cpp:6:2: note: suggested alternative: 'short'
  sort(w.begin(),w.end());
  ^~~~
  short
molecules.cpp:21:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int i=0;i<w.size();i++) {
                 ~^~~~~~~~~
molecules.cpp:31:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^