제출 #377998

#제출 시각아이디문제언어결과실행 시간메모리
377998hackermubDetecting Molecules (IOI16_molecules)C++17
69 / 100
1069 ms12024 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; //#define int long long #define pii pair<int,int> #define float long double #define fi first #define se second #define pb push_back #define all(v) v.begin(),v.end() #define sz(v) (int)v.size() #define uid uniform_int_distribution<int> #define forn(i,st,n,inc) for(int i=st;i<n;i+=inc) #define rforn(i,st,n,inc) for(int i=st-1;i>=n;i-=inc) //mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MOD = 1e9+7;//998244353; const int64_t INF = 1e18; ostream& operator<<(ostream& o,const string& s){ for(auto c:s) o<<c; return o; } template<typename F,typename S> ostream& operator<<(ostream& o,const pair<F,S>& p){ o<<"["<<p.fi<<","<<p.se<<"]"; return o; } template<typename... T,template<class...> class C> ostream& operator<<(ostream& o,const C<T...>& v){ o<<"["; int tot=0; for(auto x:v){ o<<x; if(tot<v.size()-1) o<<","; tot++; } o<<"]"; return o; } vector<string> vec_splitter(string s) { s += ','; vector<string> res; while(!s.empty()) { res.push_back(s.substr(0, s.find(','))); s = s.substr(s.find(',') + 1); } return res; } void debug_out( vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx, __attribute__ ((unused)) int LINE_NUM) { cerr << endl; } template <typename Head, typename... Tail> void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) { if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") "; stringstream ss; ss << H; cerr << args[idx] << " = " << ss.str(); debug_out(args, idx + 1, LINE_NUM, T...); } #ifdef OFFLINE clock_t Tm=clock(); #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__) #else #define debug(...) #endif std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n=sz(w); vector<int> idx(n); iota(all(idx),0); sort(all(idx),[w](int a,int b)->bool{ return w[a]<w[b]; }); int L=0,sum=0; for(int R=0;R<n;R++){ if(w[idx[R]]>u) break; sum+=w[idx[R]]; while(L<=R && sum>u){ sum-=w[idx[L]]; L++; } assert(L<=R); if(sum>=l) return vector<int>(idx.begin()+L,idx.begin()+R+1); } return {}; }
#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...