Submission #644372

#TimeUsernameProblemLanguageResultExecution timeMemory
644372vladislav11Detecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<int> find_subset ( int l, int r, vector<int> w ) { vector<int> old = w; sort( w.begin(), w.end(), greater<int>() ); vector<int> a, b; for ( auto& el : w ) { if ( l >= el ) { l -= el; r -= el; a.push_back(el); } else b.push_back(el); } /*for ( auto& el : a ) cout << el << ' '; cout << '\n'; for ( auto& el : b ) cout << el << ' '; cout << '\n';*/ if ( b.size() && b.back() <= r ) { l -= b.back(); r -= b.back(); a.push_back( b.back() ); b.pop_back(); } //cout << "! " << l << ' ' << r << '\n'; if ( 0 < l || r < 0 ) return {}; vector<int> ans; multiset<int> mst( a.begin(), a.end() ); /*for ( auto& el : mst ) cout << el << ' '; cout << '\n';*/ for ( int i=0; i<old.size(); i++ ) if ( mst.count( old[i] ) ) { mst.erase(mst.find( old[i] )); ans.push_back(i+1); } return ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, l, r; cin >> n >> l >> r; vector<int> w(n); for ( auto& el : w ) cin >> el; for ( auto& el : find_subset( l, r, w ) ) cout << el << ' '; return 0; }

Compilation message (stderr)

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