# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
500720 | aryan12 | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 296 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;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
return a.first < b.first;
}
vector<int> find_subset(int l, int r, vector<int> w) {
vector<pair<long long, long long> > a;
for(long long i = 0; i < w.size(); i++) {
a.push_back(make_pair(w[i], i));
}
sort(a.begin(), a.end(), cmp);
long long left = 0, right = 0, sum = a[0].first;
for(long long i = 1; i < a.size(); i++) {
sum += a[i].first;
if(sum > r) {
break;
}
right = i;
}
vector<int> ans;
if(sum >= l && sum <= r) {
for(long long i = 0; i <= right; i++) {
ans.push_back(a[i].second);
}
}
else {
int f = 0;
sum = 0;
for(int i = 0; i <= right; i++) {
sum += a[i].first;
}
while(right < a.size() - 1) {
left++;
right++;
sum += a[right].first;
sum -= a[left - 1].first;
if(sum >= l && sum <= r) {
f = 1;
break;
}
}
if(f == 1) {
for(long long i = left; i <= right; i++) {
ans.push_back(a[i].second);
}
}
}
return ans;
}
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... |