| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 164744 | quocnguyen1012 | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
pair<int, int> a[maxn];
int N, L, R;
ll sum[maxn];
signed main(void)
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen("A.INP", "r")){
freopen("A.INP", "r", stdin);
freopen("A.OUT", "w", stdout);
}
cin >> N >> L >> R;
for (int i=1; i<=N; ++i){
cin >> a[i].fi;
a[i].se = i;
}
sort(a+1, a+1+N);
ll sum = 0;
for (int i=1, j=1; i<=N; ++i){
sum += a[i].fi;
while (sum > R){
sum -= a[j].fi;
++j;
}
if (sum >= L){
for (int k=j; k<=i; ++k){
cout << a[k].se - 1 << ' ';
}
return 0;
}
}
}
