Submission #209867

#TimeUsernameProblemLanguageResultExecution timeMemory
209867thebesDetecting Molecules (IOI16_molecules)C++14
100 / 100
66 ms7160 KiB
#include <bits/stdc++.h> #define DEBUG 1 using namespace std; namespace output{ void __(short x){cout<<x;} void __(unsigned x){cout<<x;} void __(int x){cout<<x;} void __(long long x){cout<<x;} void __(unsigned long long x){cout<<x;} void __(double x){cout<<x;} void __(long double x){cout<<x;} void __(char x){cout<<x;} void __(const char*x){cout<<x;} void __(const string&x){cout<<x;} void __(bool x){cout<<(x?"true":"false");} template<class S,class T> void __(const pair<S,T>&x){__(DEBUG?"(":""),__(x.first),__(DEBUG?", ":" "),__(x.second),__(DEBUG?")":"");} template<class T> void __(const vector<T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");} template<class T> void __(const set<T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");} template<class T> void __(const multiset<T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");} template<class S,class T> void __(const map<S,T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");} void pr(){cout<<"\n";} template<class S,class... T> void pr(const S&a,const T&...b){__(a);if(sizeof...(b))__(' ');pr(b...);} } using namespace output; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<int,char> pic; typedef pair<double,double> pdd; typedef pair<ld,ld> pld; typedef vector<int> vi; typedef vector<ll> vl; #define pb push_back #define fox(i,x,y) for(int i=(x);i<=(y);i++) #define foxr(i,x,y) for(int i=(y);i>=(x);i--) const int MN = 2e5+5; pair<int,int> arr[MN]; long long psa[MN]; vi find_subset(int l,int u,vi w){ int mn = w[0]; int n = w.size(); for(int i=0;i<n;i++) mn = min(w[i], mn); for(int i=0;i<n;i++) arr[i]={w[i]-mn,i}; int ans = 0; vi res; sort(arr,arr+n,[](pair<int,int>i,pair<int,int>j){return i.first<j.first;}); for(int i=0;i<n;i++) psa[i+1]=psa[i]+arr[i].first; for(int i=1;i<=n;i++){ long long a=psa[i], b=psa[n]-psa[n-i]; if(a+1LL*i*mn<=1LL*u&&b+1LL*i*mn>=1LL*l){ ans = i; for(int i=ans;i<=n;i++){ long long tmp = psa[i]-psa[i-ans]+1LL*mn*ans; if(tmp>=l&&tmp<=u){ res.resize(ans); for(int j=i-ans;j<i;j++) res[j-i+ans]=arr[j].second; return res; } } } } return res; }
#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...