제출 #574404

#제출 시각아이디문제언어결과실행 시간메모리
574404EliasDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> #ifndef _DEBUG #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #include "molecules.h" #endif using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) a[i] = {w[i], i}; sort(a.begin(), a.end()); if (a[0].first > u) return {}; if (a.back().first >= l && a.back().first <= u) return {n - 1}; if (a[0].first >= l && a[0].first <= u) return {0}; int i = 0; int sum = 0; for (int j = 0; j < n; j++) { sum += a[j].first; while (sum > u) { sum -= a[i].first; i++; } if (sum >= l) { vector<int> out; for (int k = i; k <= j; k++) { out.push_back(a[k].first); } return out; } } return {}; } #ifdef _DEBUG signed main() { int n, l, u; cin >> n >> l >> u; vector<int> a(n); for (int &x : a) cin >> x; for (int x : find_subset(l, u, a)) cout << x << " "; } #endif
#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...