# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
841042 | manhlinh1501 | Detecting Molecules (IOI16_molecules) | C++17 | 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>
using namespace std;
using i64 = long long;
using pli = pair<i64,int>;
#define sz(a) (int)a.size()
#define eb emplace_back
#define all(a) a.begin(),a.end()
vector<int> find_subset(int l,int r,vector<int> a){
int n = sz(a);
vector<pli> sum(n+1,{0,0});
for(int i=0;i<n;i++){
sum[i+1].first=sum[i].first+a[i];
sum[i+1].second=i;
}
sort(all(sum));
vector<int> ans;
for(int i=1;i<=n;i++){
for(int j=i;j<=n;j++){
i64 res=sum[j].first-sum[i-1].first;
if(l<=res and res<=r){
for(int k=i;k<=j;k++)
ans.eb(sum[k].second);
return ans;
}
}
}
sort(all(ans));
return ans;
}
int n;
int l,r;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>l>>r;
vector<int> a(n);
for(int &x : a)
cin>>x;
for(int x : find_subset(l,r,a))
cout<<x<<" ";
}