Submission #888091

#TimeUsernameProblemLanguageResultExecution timeMemory
888091oblantisDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms372 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; int s = 0, j = 0; pair<int, int> p[n]; for(auto i : w) { if(i >= l && i <= u) { return {j}; } p[j] = {i, j}; j++; } sort(p, p + n); j = 0; if(p[0].ff > u || n == 1)return ans; if(p[0].ff + p[n - 1].ff > u) { if(p[0].ff + p[1].ff > u) { return ans; } else { return {p[0].ss, p[1].ss}; } } for(int i = n - 1; i > 0; i--) { ans.pb(p[i].ss); s += p[i].ff; if(s > u)break; if(s >= l)return ans; if(s + p[0].ff <= u && s + p[0].ff >= l){ ans.pb(p[0].ss); 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...