# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
448387 | bonopo | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define rc (i<<1)|1
#define lc (i<<1)
#define el "\n"
#define f first
#define s second
typedef long long ll;
const int MM=2e5+5, MOD=1e9+7;
int N, L, R; pair<int,int> a[MM];
int32_t main() {
cin.tie(nullptr)->sync_with_stdio(false);
cin>>N>>L>>R;
for(int i=1, x; i<=N; ++i) cin>>x, a[i]={x, i-1};
sort(a, a+N+1);
ll sum=0;
for(int l=1, r=1; r<=N; ++r) {
sum+=a[r].f;
while(l<r&&sum>R) sum-=a[l++].f;
if(sum>=L&&sum<=R) {
cout<<r-l+1<<el;
for(int i=l; i<=r; ++i) cout<<a[i].s<<" \n"[i==r];
return 0;
}
}
cout<<0<<el;
}
// MM