# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
994455 | SuPythony | Detecting Molecules (IOI16_molecules) | C++17 | 2 ms | 796 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 <bits/stdc++.h>
#include "molecules.h"
using namespace std;
typedef long long ll;
vector<int> find_subset(int d, int u, vector<int> w) {
vector<pair<int,int>> a;
int tot=0;
for (int i=0; i<w.size(); i++) {
a.push_back({w[i],i});
tot+=w[i];
}
sort(a.begin(),a.end());
int l=0,r=w.size()-1;
bool pos=true;
while (true) {
if (tot>u) {
tot-=a[r].first;
r--;
if (r<0) {
pos=false;
break;
}
} else if (tot<d) {
tot-=a[l].first;
l++; r++;
if (l==w.size()||r==w.size()) {
pos=false;
break;
}
tot+=a[r].first;
} else {
break;
}
}
if (!pos) return vector<int>();
vector<int> ans;
for (int i=l; i<=r; i++) ans.push_back(a[i].second);
sort(ans.begin(),ans.end());
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... |