제출 #747698

#제출 시각아이디문제언어결과실행 시간메모리
747698_martynasDetecting Molecules (IOI16_molecules)C++11
9 / 100
1 ms316 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; using ll = long long; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<int> id(n), ans; iota(id.begin(), id.end(), 0); sort(id.begin(), id.end(), [&](int i, int j) { return w[i] < w[j]; }); ll pref = 0, suff = 0; for(int i = 0; i < n; i++) { pref += w[id[i]]; suff += w[id[n-i-1]]; if(pref <= u && suff >= l) { if(pref >= l) { ans.resize(i+1); for(int k = 0; k <= i; k++) ans[k] = id[k]; return ans; } ll sum = pref; for(int j = i+1; j < n; j++) { sum -= w[j-i-1]; sum += w[j]; if(sum >= l) { ans.resize(i+1); for(int k = j-i; k <= j; k++) ans[k-(j-i)] = id[k]; return ans; } } } } return vector<int>(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...