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>
#define ll long long
#include "molecules.h"
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector <int> a;
a=w;
int n=a.size();
pair <ll, ll> jv;
jv.first=jv.second=-1;
ll res=1e9;
for (int i=0;i<n;i++){
for (int j=i;j<n;j++){
int mx=0, mn=1e9;
ll sum=0;
for (int j1=i;j1<=j;j1++){
mx=max(mx, a[i]);
mn=min(mn, a[i]);
sum+=a[i];
}
if (sum >= l and sum <= u and mx-mn <= u-l){
if (res > (j-i+1)){
res=j-i+1;
jv.first=i;
jv.second=j;
}
}
}
}
vector <int> ans;
if (jv.first == -1) ans.push_back(0);
else {
for (int i=jv.first;i<=jv.second;i++) ans.push_back(i);
}
// for (auto l:ans) cout << l <<" ";
return ans;
// return std::vector<int>(0);
}
# | 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... |