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"
using namespace std;
//#include "grader.cpp"
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int>vi;
typedef vector<vector<int>>vvi;
typedef vector<ll>vl;
typedef vector<vl> vvl;
typedef pair<int,int>pi;
typedef pair<ll,ll> pl;
typedef vector<pl> vpl;
typedef vector<ld> vld;
typedef pair<ld,ld> pld;
//typedef tree<ll, null_type, less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<typename T> ostream& operator<<(ostream& os, vector<T>& a){os<<"[";for(int i=0; i<ll(a.size()); i++){os << a[i] << ((i!=ll(a.size()-1)?" ":""));}os << "]\n"; return os;}
#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define GLHF ios_base::sync_with_stdio(false); cin.tie(NULL)
#define print(x){for(auto ait:x) cout << ait << " "; cout << "\n";}
#define pb push_back
#define umap unordered_map
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1, T2>& p){is >> p.first >> p.second;return is;}
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2>& p){os <<"" << p.first << " " << p.second << ""; return os;}
vi find_subset(int L, int U, vi W){
ll l=ll(L),u=ll(U),n=W.size();
vl w(n);
for(int i=0; i<n; i++)
w[i]=ll(W[i]);
vpl a(n);
for(int i=0; i<n; i++)
a[i]={w[i],i};
sort(all(a));
vl pref(n);
for(int i=0; i<n; i++)
pref[i]=(i?pref[i-1]:0)+a[i].first;
for(int i=0; i<n; i++){
int li=i,ri=n-1,j=-1;
while(li<=ri){
int mi=(li+ri)/2;
if(pref[mi]-(i?pref[i-1]:0)<=u)
j=mi,li=mi+1;
else
ri=mi-1;
}
if(j==-1 || pref[j]-(i?pref[i-1]:0)<l)continue;
vi ans;
for(int k=i;k<=j; k++)
ans.pb(a[k].second);
sort(all(ans));
return ans;
}
return {};
}
# | 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... |