Submission #636098

#TimeUsernameProblemLanguageResultExecution timeMemory
636098yogesh_saneDetecting Molecules (IOI16_molecules)C++17
69 / 100
43 ms5548 KiB
#include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<pair<int, int>> mol; vector<int> ans; int n = w.size(); for(int i = 0; i < n; i++) mol.push_back({w[i],i}); sort(mol.begin(), mol.end()); int lo = 0, hi = 0, sum = mol[0].first; while(sum < l || sum > u){ if(sum < l){ if(hi < n-1){ hi++; sum += mol[hi].first; }else{ break; } }else if(sum > u){ if(lo < n-1){ sum -= mol[lo].first; lo++; }else{ break; } } } if(l <= sum && sum <= u){ for(int i = lo; i <= hi; i++) ans.push_back(mol[i].second); } 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...