Submission #888103

#TimeUsernameProblemLanguageResultExecution timeMemory
888103oblantisDetecting Molecules (IOI16_molecules)C++17
69 / 100
2 ms604 KiB
#include <bits/stdc++.h> #include "molecules.h" #define all(v) v.begin(), v.end() #define pb push_back #define ss second #define ff first #define vt vector using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, int> pdi; const int inf = 1e9 + 10000; const int mod = 1e9+7; const int maxn = 5e5 + 12; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vi ans, ns; int s = 0, j = 0, o = n - 1; pair<int, int> p[n]; for(auto i : w) { if(i >= l && i <= u) { return {j}; } if(s < l)s += i; p[j] = {i, j}; j++; } if(s < l) return ans; sort(p, p + n); s = j = 0; if(p[0].ff > u || n == 1)return ans; if(p[0].ff + p[1].ff > u) { return ans; } while(j < n && s + p[j].ff <= u) { ans.pb(p[j].ss); s += p[j].ff; j++; } if(s >= l) return ans; j--; while(j >= 0 && s <= l) { s -= p[j].ff; s += p[o].ff; ns.push_back(p[o].ss); o--; j--; ans.pop_back(); } if(s >= l){ ans.insert(ans.end(), all(ns)); return ans; } return vi(0); }
#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...