Submission #491988

#TimeUsernameProblemLanguageResultExecution timeMemory
491988aciDetecting Molecules (IOI16_molecules)C++14
69 / 100
41 ms3396 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pi; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int> sol; int n = w.size(); vector<pi> v(n); for (int i=0; i<n; i++) v[i] = {w[i], i}; sort(v.begin(), v.end()); int j = 0; int sum = 0; for (int i=0; i<n; i++) { while(j < n && sum<l) { sum += v[j].first; j++; } if(sum>=l && sum<=u) { for (int k=i; k<j; k++) sol.push_back(v[k].second); //cout << "i: "<<i<<" j: "<<j<<endl; return sol; } else sum -= v[i].first; } return sol; }
#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...