Submission #1050748

#TimeUsernameProblemLanguageResultExecution timeMemory
1050748vqpahmadDetecting Molecules (IOI16_molecules)C++14
0 / 100
0 ms348 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; #ifdef ONPC #include"debug.h" #else #define debug(...) 42 #endif #define endl '\n' #define ll long long #define pii pair<int,int> #define F first #define S second #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } const int mod = 1e9 + 7; const int MAXN = 1e6 + 15; const int inf = 0x3f3f3f3f; const ll INF = 0x3f3f3f3f3f3f3f3f; vector<int> find_subset(int l, int u, vector<int> w) { sort(all(w)); deque<int> dq; int cur = 0; bool ok = 0; for (int i = 0; i < sz(w) && !ok; i++){ if (cur + w[i] <= u) { dq.pb(i + 1); cur += w[i]; } else if (sz(dq)){ cur -= w[dq.front() - 1]; dq.pop_front(); dq.pb(i + 1); cur += w[i]; } ok |= (cur >= l && cur <= u); } vector<int> ans = {0}; if (ok){ ans.clear(); for (auto it : dq) ans.pb(it); } 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...