Submission #1071679

#TimeUsernameProblemLanguageResultExecution timeMemory
1071679kukukDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms432 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int ukr = 2e5+10; vector<pair<int,int>> ar; vector<int> ans; vector<int> find_subset(int l, int u, vector<int> w) { int n; n = w.size(); for(int i = 0; i < n; i++){ ar.push_back({w[i], i+1}); } sort(ar.begin(), ar.end()); ll tot = 0; int ki = 0, ka = 0; while(ki < n){ while(ka < n && tot+ar[ka].first <= u){ tot += ar[ka].first; ka++; } //cout << ki << " " << ka << " " << tot << " " << ar[ki].first << "\n"; if(tot >= l && tot <= u){ for(int i = ki; i < ka; i++){ ans.push_back(ar[i].second); } return ans; } tot -= ar[ki].first; ki++; if(tot >= l && tot <= u){ for(int i = ki; i < ka; i++){ ans.push_back(ar[i].second); } return ans; } } return ans; } /* int main() { int n, l, u; assert(3 == scanf("%d %d %d", &n, &l, &u)); std::vector<int> w(n); for (int i = 0; i < n; i++) assert(1 == scanf("%d", &w[i])); std::vector<int> result = find_subset(l, u, w); printf("%d\n", (int)result.size()); for (int i = 0; i < (int)result.size(); i++) printf("%d%c", result[i], " \n"[i == (int)result.size() - 1]); } */
#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...