Submission #139421

#TimeUsernameProblemLanguageResultExecution timeMemory
139421quotitquotDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h" #define ll long long #define pb push_back #define fr first #define se second using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int>res; ll now = 0; vector<pair<ll,ll>>V; for( int i = 0; i < w.size(); i ++ ) V.pb( { w[i], i } ); sort( V.begin(), V.end() ); if( V[0].fr <= u ) { for( int i = 0; i < V.size(); i ++ ) { now += V[i].fr; res.pb( V[i].se ); while( now > u ) { now -= V[res[0]].fr; res.erase( res.begin() ); } if( now >= l ) { sort( res.begin(), res.end() ); return res; } } } res.pb( 0 ); return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for( int i = 0; i < w.size(); i ++ )
                     ~~^~~~~~~~~~
molecules.cpp:14:5: error: 'sort' was not declared in this scope
     sort( V.begin(), V.end() );
     ^~~~
molecules.cpp:14:5: note: suggested alternative: 'short'
     sort( V.begin(), V.end() );
     ^~~~
     short
molecules.cpp:17:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for( int i = 0; i < V.size(); i ++ )
                         ~~^~~~~~~~~~