# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
567352 | physics07 | Detecting Molecules (IOI16_molecules) | C++17 | 57 ms | 6180 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n=(int)w.size();
vector<pair<int, int>> v;
for(int i=0; i<n; i++) v.push_back({w[i], i});
sort(v.begin(), v.end());
int left=0, right=0;
bool b=0;
ll sum=v[0].first;
while(left<n && right<n) {
if(sum>=l && sum<=u) {
b=1;
break;
}
if(sum<l && right<n-1 || left==right) sum+=v[++right].first;
else sum-=v[left++].first;
}
if(b) {
vector<int> ans;
for(int i=left; i<=right; i++) ans.push_back(v[i].second);
return ans;
}
else return vector<int>(0);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |