# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260379 | Bill_00 | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KiB |
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>
typedef long long ll;
#define fr(i,c,d) for(ll i=c;i<=d;i++)
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
//int h[200001],p[200001];
//int sum[100001];
//pair<ll,ll>p[100001];
//pair<ll,ll>p1[100001];
//string s;
string str(string x,int l,int r){
string h;
for(int i=l;i<=r;i++){
h+=x[i];
}
return h;
}
ll a[200001];
pair<int,int>p[200001];
int main(){
//int color[200001];
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n,l,u;
cin >> n >> l >> u;
for(int i=1;i<=n;i++){
cin >> a[i];
p[i]=mp(a[i],i);
}
sort(p+1,p+n+1);
ll sum=0,id=0;
for(int i=1;i<=n;i++){
sum+=p[i].ff;
if(sum>=l && sum<=u){
for(int j=1;j<=i;j++){
cout << p[i].ss << ' ';
}
return 0;
}
if(sum>=l){
sum-=p[i].ff;
id=i-1;
break;
}
}
//cout << id << endl;
if(id==0){
cout << 0;
return 0;
}
for(int i=id;i>=1;i--){
sum=sum-p[i].ff;
sum=sum+p[i+n-id].ff;
//cout << sum << endl;
if(sum>=l){
for(int j=1;j<i;j++){
cout << p[j].ss << ' ';
}
for(int j=i+n-id;j<=n;j++){
cout << p[j].ss << ' ';
}
return 0;
}
}
cout << 0;
}