Submission #393819

#TimeUsernameProblemLanguageResultExecution timeMemory
393819teehandsomeDetecting Molecules (IOI16_molecules)C++11
0 / 100
1097 ms204 KiB
#include "molecules.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define endl '\n' #define INF 1e9+7 #define all(x) x.begin(),x.end() using namespace std; using namespace __gnu_pbds; using ll=long long; using pii=pair<int,int>; using ppi=pair<int,pii>; using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>; template<typename T> void _print(vector<T> x) {cerr<<"{"; for(auto e:x) cerr<<e<<","; cerr<<"}";} void _print(pii x) {cerr<<"{"<<x.first<<","<<x.second<<"}";} template<typename T> void _print(T x) {cerr<<x;} void dbg() {cerr<<endl;} template<typename Head,typename... Tail> void dbg(Head H,Tail... T) { _print(H); if(sizeof...(T)) cerr<<","; else cerr<<"\"]"; dbg(T...); } #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__) //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<int> ww; vector<int> f(int l,int r) { vector<int> ans; for(int i=l;i<r;i++) { ans.push_back(ww[i]); } return ans; } std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n=w.size(); ww=w; sort(all(w)); ll sumall=accumulate(all(w),0LL); if(sumall<l or w[0]>u) return vector<int>(0); int L=0,R=0; ll sum=0; while(R<n) { while(R+1<n and sum<l) { sum+=w[R++]; } if(sum>=l and sum<=u) { return f(L,R); } while(L+1<=R and sum>u) { sum-=w[L++]; } if(sum>=l and sum<=u) { return f(L,R); } } assert(false); }
#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...