제출 #742564

#제출 시각아이디문제언어결과실행 시간메모리
742564oyberDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms292 KiB
#include "molecules.h" #include <algorithm> #include <utility> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n = int(w.size()); vector<pair<int, int>> ws; for (int i = 0; i < n; i++) { ws.push_back(make_pair(w[i], i)); } sort(ws.begin(), ws.end()); int a = ws[0].first; vector<int> s1(n+1); vector<int> s2(n+1); for (int i = 0; i < n; i++) { ws[i].first -= a; s1[i+1] = s1[i]+ws[i].first; } for (int i = 0; i < n; i++) { s2[i+1] = s2[i]+ws[n-i-1].first; } for (int i = 0; i <= n; i++) { //printf("%d %d, %d %d\n", l, u, s1[i], s2[i]); if (s1[i] >= l && s1[i] <= u) { vector<int> result; for (int j = 0; j < i; j++) { result.push_back(ws[j].second); } return result; } if (s2[i] >= l && s2[i] <= u) { vector<int> result; for (int j = n-1; j >= n-i; j--) { result.push_back(ws[j].second); } return result; } l -= a; u -= a; } 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...