Submission #154938

#TimeUsernameProblemLanguageResultExecution timeMemory
154938jovan_bDetecting Molecules (IOI16_molecules)C++17
100 / 100
64 ms7160 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; pair <ll, ll> niz[200005]; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n = w.size(); ll L = l, R = u; for(int i=1; i<=n; i++){ niz[i].first = w[i-1]; niz[i].second = i-1; } int lg=1, r=1; sort(niz+1, niz+1+n); ll sum=niz[1].first; vector <int> arr; while(r <= n){ if(sum <= R && sum >= L){ //cout << r-l+1 << "\n"; for(int i=lg; i<=r; i++) arr.push_back(niz[i].second); return arr; } else if(sum > R) {sum -= niz[lg].first; lg++;} else if(sum < L) {r++; sum += niz[r].first;} } return arr; }
#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...