Submission #309487

#TimeUsernameProblemLanguageResultExecution timeMemory
309487radaiosm7Detecting Molecules (IOI16_molecules)C++98
100 / 100
60 ms4208 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> ans; vector<pair<int,int>> p; int i, j, n; long long sum; std::vector<int> find_subset(int l, int u, std::vector<int> w) { n = w.size(); for (i=0; i < n; i++) { p.push_back(make_pair(w[i], i)); } sort(p.begin(), p.end ()); i = 0; j = 0; sum = (long long)p[0].first; while (j < n) { if ((long long)l <= sum && sum <= (long long)u) { break; } else if (sum < (long long)l) { if (j+1 == n) { break; } sum += (long long)p[++j].first; } else { sum -= (long long)p[i++].first; } } if (l <= sum && sum <= u) { for (int x=i; x <= j; x++) { ans.push_back(p[x].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...