Submission #887927

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