# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
260379 | Bill_00 | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}