Submission #719948

#TimeUsernameProblemLanguageResultExecution timeMemory
719948vinnipuh01Detecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { set <int> st, s; int sum = 0; for ( auto i : w ) { if ( sum + i <= l ) st.insert( i ), sum += i; else s.insert( i ); } while ( s.size() && sum < l ) { sum += *s.rbegin() - *st.begin(); st.erase( st.begin() ); st.insert( *s.rbegin() ); s.erase( --s.end() ); } vector <int> v; v.clear(); if ( sum < l ) return v; for ( auto i : st ) v.push_back( i ) return v; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:26:19: error: expected ';' before 'return'
   26 |   v.push_back( i )
      |                   ^
      |                   ;
   27 |     return v;
      |     ~~~~~~         
molecules.cpp:7:12: warning: control reaches end of non-void function [-Wreturn-type]
    7 |  set <int> st, s;
      |            ^~