#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define gcd __gcd
#define sz(v) (int) v.size()
#define pb push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define compact(v) (v).erase(unique(all(v)), (v).end())
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define dbg(x) "[" #x " = " << (x) << "]"
///#define int long long
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template<typename T> bool ckmx(T& a, const T& b){if(a < b) return a = b, true; return false;}
template<typename T> bool ckmn(T& a, const T& b){if(a > b) return a = b, true; return false;}
const int N = 2e5+5;
const ll MOD = 1e9+7;
const ll INF = 1e18;
vector<int> find_subset(int l, int r, vector<int> w){
vector<pair<int,int>> a;
for(int i = 0; i < sz(w); i++) a.push_back(make_pair(w[i], i));
vector<int> answer; sort(all(a));
int ptr = 0, sum = 0;
for(int i = 0; i < sz(w); i++){
sum += a[i].fi;
while(ptr <= i && sum > r) sum -= a[ptr++].fi;
if(l <= sum && sum <= r){
for(int x = ptr; x <= i; x++)
answer.pb(a[x].se + 1);
break;
}
}
return answer;
}
//#define name "InvMOD"
#ifdef name
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if(fopen(name".INP", "r")){
freopen(name".INP","r",stdin);
freopen(name".OUT","w",stdout);
}
int n, l, r; cin >> n >> l >> r;
vector<int> w;
FOR(i, 1, n){
int x; cin >> x;
w.push_back(x);
}
vector<int> ans = find_subset(l, r, w);
for(int v : ans) cout << v << " "; cout <<"\n";
return 0;
}
#endif
Compilation message (stderr)
molecules.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |