# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
377327 | rrrr10000 | Detecting Molecules (IOI16_molecules) | C++14 | 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;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++)
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define rosrt(a) {sort(all(a));reverse(all(a));}
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];};cout<<'\n';}
template<class T> void outvv(T v){for(auto x:v)outv(x);}
template<class T> void outp(T p){cout<<'('<<p.fi<<','<<p.se<<')'<<endl;}
template<class T> void outvp(T v){for(auto x:v)cout<<'('<<x.fi<<','<<x.se<<')';cout<<endl;}
vi find_subset(int a,int b,vi v){
int n=v.size();
vi ruil(n),ruir(n);
rep(i,n){
ruil[i]=v[i];
if(i)ruil[i]+=ruil[i-1];
}
for(int i=n-1;i>=0;i--){
ruir[i]=v[i];
if(i!=n-1)ruir[i]+=ruir[i+1];
}
rep(i,n){
if(ruil[i]<=b&&ruir[n-i-1]>=a){
ll sum=ruil[i];
int l=i+1;
rep(j,i+1){
if(sum>=a)break;
sum-=v[j];
sum+=v[n-j-1];
l--;
}
vi res(i+1);
rep(j,i+1){
if(j<l)res[j]=v[j];
else res[j]=v[n-(j-l)-1];
}
return res;
}
}
vi res(0);
return res;
}