Submission #644468

#TimeUsernameProblemLanguageResultExecution timeMemory
644468vladislav11Detecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; vector<int> find_subset ( int l, int r, vector<int> w ) { int n = w.size(); vector< pair<int,int> > a(n); for ( int i=0; i<n; i++ ) a[i] = { w[i], i+1 }; sort( a.begin(), a.end() ); vector<int> mini(n+1), maxi(n+1); mini[1] = a[0].first; maxi[1] = a[n-1].first; for ( int i=2; i<=n; i++ ) { mini[i] = mini[i-1] + a[i-1].first; maxi[i] = maxi[i-1] + a[n-i].first; } for ( int i=1; i<=n; i++ ) if ( mini[i] <= r && l <= maxi[i] ) { deque<int> ans; int sum = mini[i]; for ( int j=0; j<i; j++ ) ans.push_back( a[j].second ); for ( int j = i; sum < l; j++ ) { sum -= ans.front(); ans.pop_front(); sum += a[j].first; ans.push_back( a[j].second ); } vector<int> ret; while ( ans.size() ) { ret.push_back( ans.back() ); ans.pop_back(); } return ret; } return {}; }
#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...