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"
//#include "grader.cpp"
using namespace std;
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << #i << " " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<int,int>pii;
typedef array<int,4>pi2;
vector<int>find_subset(int l, int u, vector<int>w){
int n=w.size();
int counter=0;
int ptr=-1;
pii arr[n];
for(int x=0;x<n;x++) arr[x]={w[x],x};
sort(arr,arr+n);
for(int x=0;x<n;x++){
if(counter+arr[x].first>u) break;
counter+=arr[x].first;
ptr=x;
}
//show(counter,counter);
vector<int>ans;
if(counter>=l){
for(int y=0;y<=ptr;y++) ans.push_back(arr[y].second);
return ans;
}
int cur=n-1;
for(int x=ptr;x>=0;x--){
counter+=arr[cur].first;
counter-=arr[x].first;
//cur--;
//show2(x,x,counter,counter);
if(counter>=l&&counter<=u){
for(int y=0;y<x;y++){
ans.push_back(arr[y].second);
}
for(int y=n-1;y>=cur;y--){
ans.push_back(arr[y].second);
}
return ans;
}
cur--;
}
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... |