Submission #591361

#TimeUsernameProblemLanguageResultExecution timeMemory
591361FatihSolakDetecting Molecules (IOI16_molecules)C++17
100 / 100
56 ms5960 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int r, vector<int> w) { vector<int> ans; int n = w.size(); vector<pair<int,int>> v; for(int i = 0;i<n;i++){ v.push_back({w[i],i}); } sort(v.begin(),v.end()); long long sum = 0; long long sufsum = 0; for(auto u:w)sufsum += u; int pt2 = 0; for(int i = 0;i<=n;i++){ if(i) sum += v[i-1].first; while(pt2 != n && (pt2 < i || sufsum + sum > r)){ sufsum -= v[pt2].first; pt2++; } if(l <= sum + sufsum && sum + sufsum <= r){ for(int c = 0;c<i;c++){ ans.push_back(v[c].second); } for(int c = n-1;c>=pt2;c--){ ans.push_back(v[c].second); } return ans; } } return ans; }
#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...