이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
#define pb push_back
#define pi pair<int,int>
#define ll long long
#define mp make_pair
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<pi> sorted(n);
for(int i =0;i<n ; i++)
sorted[i] = {w[i], i};
sort(sorted.begin(), sorted.end());
int lpntr = -1, rpntr = -1;
for(int k = 0; k< n; k++){
ll curans = 0;
int left = 0;
int right = left + k;
for(int i =left; i <= right; i++)
curans+=sorted[i].first;
if(curans >=l and curans <= u){
lpntr = left;
rpntr = right;
break;
}
bool won = false;
while(curans <l){
if(left >=n)
break;
curans -= sorted[left].first;
left++;
right++;
if(right >= n)
break;
curans += sorted[right].first;
if(curans >= l and curans <= u)
{
won = true;
break;
}
else if(curans >= u || right == n-1)
{
won = false;
break;
}
}
if(won){
lpntr = left;
rpntr = right;
break;
}
}
if(lpntr == -1 and rpntr == -1)
return vector<int> ();
vector<int> ans;
for(int i = max(0,lpntr); i<= rpntr; i++)
ans.pb(sorted[i].second);
sort(ans.begin(), ans.end());
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... |