이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "molecules.h"
#define endl '\n'
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
vector<int> find_subset(int l,int u,vector<int> w)
{
int n=w.size();
vector<pair<int,int>> ww;
vector<ll> ssum;
for(int i=0; i<n; i++) ww.push_back({w[i],i});
sort(ww.begin(),ww.end());
ll sum=0;
for(int i=0; i<n; i++)
{
sum+=ww[i].F;
ssum.push_back(sum);
}
ll idx=0;
while(idx<n && ssum[idx]<l) ++idx;
if(idx<n && ssum[idx]<=u)
{
vector<int> result;
for(int i=0; i<=idx; i++) result.push_back(ww[i].S);
return result;
}
for(int i=0; i<n; i++)
{
while(idx<n && ssum[idx]-ssum[i]<l) ++idx;
if(idx<n && ssum[idx]-ssum[i]<=u)
{
vector<int> result;
for(int j=0; j<=idx; j++) result.push_back(ww[j].S);
return result;
}
}
return vector<int> ();
}
/*
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,l,u;
cin>>n>>l>>u;
vector<int> w(n);
for(int i=0; i<n; i++) cin>>w[i];
vector<int> result=find_subset(l,u,w);
cout<<(int)result.size()<<endl;
for(int i=0; i<(int)result.size(); i++) cout<<result[i]<<' ';
return 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... |