Submission #1063024

#TimeUsernameProblemLanguageResultExecution timeMemory
1063024nvujicaDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms604 KiB
#include <bits/stdc++.h> #include "molecules.h" #define ll long long using namespace std; const int maxn = 1e4 + 10; int n; ll pref[maxn]; ll suf[maxn]; vector<int> find_subset(int l, int u, vector<int> w) { n = w.size(); sort(w.begin(), w.end()); pref[0] = w[0]; suf[n - 1] = w[n - 1]; for(int i = 1; i < n; i++){ pref[i] = pref[i - 1] + w[i]; } for(int i = n - 2; i >= 0; i--){ suf[i] = suf[i + 1] + w[i]; } vector <int> v; for(int k = 1; k <= n; k++){ // cout << k << " " << pref[k - 1] << endl; if(pref[k - 1] <= u && suf[n - k] >= l){ // cout << k << endl; int sum = pref[k - 1]; int x = 0; while(sum < l){ sum -= w[x]; sum += w[n - x - 1]; x++; } for(int i = x; i < k; i++) v.push_back(i); for(int i = n - x; i < n; i++) v.push_back(i); return v; } } return v; }
#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...