이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "molecules.h"
#pragma GCC optimize("O2,unroll-loops")
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define en cin.close();return 0;
#define pb push_back
#define fi first//printf("%lli\n",cur);
#define se second//scanf("%lli",&n);
#define r0 return 0;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> find_subset(int l, int u, vector<int> inp)
{
int n = inp.size();
ll pf[n+1], sf[n+2];
vector<pair<int,int> > w(n+1);
for(int i = 1;i<=n;i++)
w[i]={inp[i-1],i};
sort(w.begin(),w.end());
pf[0]=sf[n+1]=0;
for(int i = 1;i<=n;i++)
pf[i]=pf[i-1]+w[i].fi,
sf[n-i+1]=sf[n-i+2]+w[n-i+1].fi;
if(pf[n]<l||u<pf[1])
return {};
for(int i = 1;i<=n;i++)
{
if(l<=pf[i]&&pf[i]<=u)
{
vector<int> ret;
for(int j = 1;j<=i;j++)
ret.pb(w[j].se);
return ret;
}
}
int k = 1;
while(k<n&&pf[k+1]<l)
k++;
if(sf[n-k+1]<l)
return {};
vector<int> ans(k);
for(int i = 1;i<=k;i++)
ans[i]=w[i].se;
ll cur = pf[k];
for(int i = 1;cur<l;i++)
cur-=w[i].fi,
cur+=w[n-i+1].fi,
ans[i-1]=w[n-i+1].se;
sort(ans.begin(),ans.end());//style points
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... |