This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//In the name of God
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
vector<int> find_subset(int l, int r, vector<int> w){
vector<int> ans;
vector<pll> a;
for(ll i = 0; i < Sz(w); i++){
if(w[i] <= r){
a.pb(Mp(w[i], i));
}
}
ll n = Sz(a);
sort(all(a));
ll ps1 = 0, ps2 = 0;
for(ll i = 0; i < n; i++){
ps1 += a[i].F;
ps2 += a[n - i - 1].F;
if(ps1 > r || ps2 < l) continue;
if(l <= ps1){
for(ll j = 0; j <= i; j++){
ans.pb(a[j].S);
}
return ans;
}
for(ll j = i + 1; j < n; j++){
ps1 += a[j].F - a[j - i - 1].F;
if(l <= ps1){
for(ll k = j - i; k <= j; k++){
ans.pb(a[k].S);
}
return ans;
}
}
}
return ans;
}
/*int main(){
fast_io;
return 0;
}*/
# | 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... |