제출 #957060

#제출 시각아이디문제언어결과실행 시간메모리
957060inkvizytorDetecting Molecules (IOI16_molecules)C++11
0 / 100
1 ms348 KiB
#include "molecules.h" #define fi first #define se second #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n = w.size(); vector<pair<int, int>> s; for (int i = 0; i < n; i++) { s.push_back(make_pair(w[i], i+1)); } sort(s.begin(), s.end()); vector<int> sp (n, 0); vector<int> ss (n, 0); sp[0] = s[0].fi; ss[n-1] = s[n-1].fi; for (int i = 1; i < n; i++) { sp[i] = sp[i-1]+s[i].fi; ss[n-1-i] = ss[n-i]+s[n-1-i].fi; } for (int i = 0; i < n; i++) { if (sp[i] <= u && ss[n-1-i] >= l) { vector<int> v; int sum = 0; for (int j = 0; j <= i; j++) { v.push_back(s[j].se); sum += s[j].fi; } for (int j = 0; j <= i; j++) { if (sum < l) { sum -= s[j].fi; sum += s[n-1-j].fi; v[j] = s[n-1-j].se; } } return v; } cout << i << ' ' << sp[i] << ' ' << ss[n-1-i] << '\n'; } 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...