Submission #216285

#TimeUsernameProblemLanguageResultExecution timeMemory
216285HNO2Detecting Molecules (IOI16_molecules)C++17
69 / 100
67 ms10360 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=2e5+7; const int inf=INT_MAX; const ll inff=1e18; const ll mod=1e9+7; #define pii pair<ll,ll> #define mkp make_pair #define F first #define S second #define pb push_back #define sz(v) ((int)(v).size()) #define all(v) (v).begin(),(v).end() //#define int ll #ifdef HNO2 #define IOS #else #define endl '\n' #define IOS ios::sync_with_stdio(0); cin.tie(0); #endif // HNO2 int n; pii a[maxn]; ll pre[maxn],suf[maxn]; std::vector<int> find_subset(int l, int u, std::vector<int> w) { n=sz(w); for (int i=0;i<n;i++) a[i+1]=mkp(w[i],i); sort(a+1,a+n+1); for (int i=1;i<=n;i++) pre[i]=pre[i-1]+a[i].F; for (int i=n;i>=1;i--) suf[i]=suf[i+1]+a[i].F; for (int i=1;i<=n;i++) { if (min(suf[n-i+1],ll(u))-max(pre[i],ll(l))>=0) { vector<int> ret; int tmp1,tmp2; int L=0,R=i*(n-i+1); while (R-L>1) { int M=(L+R)>>1; tmp1=(M-1)/(n-i+1),tmp2=(M-1)%(n-i+1); if (pre[i-tmp1-1]+suf[n+1-tmp1]+a[tmp2+(i-tmp1)].F>=l) R=M; else L=M; } tmp1=(R-1)/(n-i+1),tmp2=(R-1)%(n-i+1); for (int j=1;j<=i-tmp1-1;j++) ret.pb(a[j].S); ret.pb(a[tmp2+(i-tmp1)].S); for (int j=n+1-tmp1;j<=n;j++) ret.pb(a[j].S); return ret; } } return vector<int> (); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...