# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
719970 | vinnipuh01 | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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() > u ) {
vector <int> v;
return v;
}
else if ( w.front() <= u && w.front() >= l ) {
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 } );
}
assert( st.size() != 0 );
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() );
if ( sum >= l )
break;
}
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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |