Submission #531394

#TimeUsernameProblemLanguageResultExecution timeMemory
531394tkwiatkowskiDetecting Molecules (IOI16_molecules)C++17
31 / 100
4 ms492 KiB
/* Zadanie: Detecting Molecules Autor: Tomasz Kwiatkowski */ #include <bits/stdc++.h> #include "molecules.h" #define fi first #define se second #define pb push_back using namespace std; typedef long long ll; const int MAXN = 1e6 + 7; const int INF = 1e9 + 7; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pair<int, int>> molecules(n); for (int i = 0; i < n; ++i) molecules[i] = {w[i], i}; sort(molecules.begin(), molecules.end()); vector<int> ans; int r = 0; ll sum = 0; for (int left = 0; left < n; ++left) { while (r < n && sum + molecules[r].fi <= u) { sum += molecules[r].fi; if (l <= sum) { for (int i = left; i <= r; ++i) ans.pb(molecules[i].se); return ans; } ++r; } sum -= molecules[left].fi; r = max(r, left + 1); } 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...