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>
#include "molecules.h"
//#define int long long
#define pb push_back
#define F first
#define S second
using namespace std;
const int N = 110;
const int mod = 1e9+7;
const int inf = 1e18;
vector<int>find_subset(int l,int r,vector<int>a) {
int n = a.size();
vector<pair<int,int>>v;
for(int i=0;i<n;i++) {
v.pb({a[i],i});
}
sort(v.begin(),v.end());
vector<int>res;
int i=0,j=0,s = 0;
while(i < n && j < n) {
//cout << s << ' ' << i << ' ' << j << endl;
if(s >= l && s <= r) {
for(int k=i;k<j;k++) res.pb(v[k].S);
break;
}
if(s > r) {
s -= v[i++].F;
}
else s += v[j++].F;
}
return res;
}
/*signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n,l,r;
vector<int>a;
cin >> n >> l >> r;
for(int i=0;i<n;i++) {
int x;
cin >> x;
a.pb(x);
}
vector<int>res = find_subset(l,r,a);
for(int i=0;i<res.size();i++) cout << res[i] << ' ';
}*/
Compilation message (stderr)
molecules.cpp:19:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
19 | const int inf = 1e18;
| ^~~~
# | 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... |