Submission #252618

#TimeUsernameProblemLanguageResultExecution timeMemory
252618ChrisTDetecting Molecules (IOI16_molecules)C++17
69 / 100
63 ms5624 KiB
#include<bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pair<int,int>> v(n); for (int i = 0; i < n; i++) v[i] = {w[i],i}; sort(v.begin(),v.end()); int low = v[0].first; for (pair<int,int> &p : v) p.first -= low; long long sumHigh = 0, sumLow = 0; for (int sz = 1; sz <= n; sz++) { //sum + low * sz >= l ? sumHigh += v[n-sz].first; sumLow += v[sz-1].first; if (sumHigh + low * sz >= l && sumLow + low * sz <= u) { //found an answer long long cur = sumLow + low * sz; for (int st = 0; st < n; st++) { if (st) cur -= v[st-1].first, cur += v[st+sz-1].first; if (l <= cur && cur <= u) { vector<int> ret; for (int j = st; j < st + sz; j++) ret.push_back(v[j].second); 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...