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>
using namespace std;
// #define int long long
#define pint pair < int , int >
#define ll long long
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL); cin.tie(NULL)
const int inf = 1e9 + 9;
const int mxn = 2e5 + 2;
const int mod = 1e9 + 7;
vector < int > find_subset(int l , int r , vector < int > w) {
int n = w.size();
vector < pint > v;
for (int i = 0; i < n; i++) {
v.push_back({w[i] , i});
}
sort(v.begin() , v.end());
vector < int > ans , rep;
int sum = 0 , id1 = 0;
while (id1 < n) {
sum += v[id1].ff;
ans.push_back(v[id1].ss);
if (sum >= l) break;
}
if (sum <= r) return ans;
sum -= v[id1].ss;
ans.pop_back();
id1--;
int id2 = n-1;
while (id1 >= 0 && id2 > id1) {
sum += v[id2].ss - v[id1].ss;
ans.pop_back();
rep.push_back(id2);
id2--;
id1--;
if (sum >= l && sum <= r) {
for (int i : rep) ans.push_back(i);
return ans;
}
}
ans.clear();
return ans;
}
# | 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... |