Submission #440955

#TimeUsernameProblemLanguageResultExecution timeMemory
440955julian33Detecting Molecules (IOI16_molecules)C++14
100 / 100
71 ms6184 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; #ifdef LOCAL #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) { cerr<<vars<<" = "; string delim=""; (...,(cerr<<delim<<values,delim=", ")); cerr<<"\n"; } #else #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) {} #endif #define pb push_back #define sz(x) (int)(x.size()) typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; template<typename T> inline void maxa(T& a,T b){a=max(a,b);} template<typename T> inline void mina(T& a,T b){a=min(a,b);} vector<int> find_subset(int l, int u, vector<int> w){ int n=sz(w); vector<pii> W; for(int i=0;i<n;i++) W.pb({w[i],i}); sort(W.begin(),W.end()); ll sum=0; int j=n+5; vector<int> ans; for(int i=0;i<n;i++){ if(sum+W[i].first>u){ j=i; break; } sum+=W[i].first; ans.pb(W[i].second); } for(int i=n-1;i>=j && n-i-1<j && sum<l;i--){ sum+=W[i].first-W[n-i-1].first; ans[n-i-1]=W[i].second; } if(sum<l || sum>u) return {}; sort(ans.begin(),ans.end()); return ans; }
#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...