Submission #740498

#TimeUsernameProblemLanguageResultExecution timeMemory
740498JakobZorzDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h" using namespace std; #define ll long long vector<int> find_subset(int l, int u, vector<int> w) { int m1=0,m2=0; int sum=0; sort(w.begin(),w.end()); while(sum<l&&m2<w.size()) sum+=w[m2++]; while(sum>u&&m1<m2) sum-=w[m1++]; if(sum>=l&&sum<=u){ vector<int> res; for(int i=m1;i<m2;i++) res.push_back(w[i]); return res; } else return {}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:5: error: 'sort' was not declared in this scope; did you mean 'short'?
    8 |     sort(w.begin(),w.end());
      |     ^~~~
      |     short
molecules.cpp:9:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     while(sum<l&&m2<w.size())
      |                  ~~^~~~~~~~~