Submission #719955

#TimeUsernameProblemLanguageResultExecution timeMemory
719955vinnipuh01Detecting Molecules (IOI16_molecules)C++17
0 / 100
0 ms212 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector <int> v; vector<int> find_subset(int l , int u , vector<int> w) { set <pair<int, int> > st, s; int sum = 0; sort( w.begin(), w.end() ); if ( w.front() > l ) { vector <int> v; return v; } else if ( w.front() <= u ) { vector <int> v; v.push_back( 0 ); return v; } for ( int i = 0; i < w.size(); i ++ ) { if ( sum + w[ i ] <= l ) st.insert( { w[ i ], i } ), sum += w[ i ]; else s.insert( { w[i ], i } ); } while ( s.size() && sum < l ) { if ( st.size() ) sum += s.rbegin()->first - st.begin()->first; else sum += s.rbegin()->first; if ( st.size() ) 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.second ); return v; } //main () { // int l, r; // cin >> l >> r; // int n; // cin >> n; // int num; // for ( int i = 1; i <= n; i ++ ) { // cin >> num; // v.push_back( num ); // } // v = find_subset( l, r, v ); // for ( auto i : v ) // cout << i << " "; //}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:21:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for ( int i = 0; i < w.size(); i ++ ) {
      |                   ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...