제출 #388987

#제출 시각아이디문제언어결과실행 시간메모리
388987apostoldaniel854Detecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define dbg(x) cerr << #x << " " << x << "\n" //#define HOME #ifndef HOME #include "molecules.h" #endif // HOME std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n = w.size (); vector <pair <int, int>> v (n); for (int i = 0; i < n; i++) v[i] = {w[i], i}; int lb = 0, rb = 0; int sum = v[0].first; while (rb < n) { if (sum >= l && sum <= u) { vector <int> sol; for (int i = lb; i <= rb; i++) sol.push_back (v[i].second); return sol; } if (sum < l && lb < n) sum += v[++lb].first; else sum -= v[rb++].first; } return {}; } #ifdef HOME int main() { int n, l, u; assert(3 == scanf("%d %d %d", &n, &l, &u)); std::vector<int> w(n); for (int i = 0; i < n; i++) assert(1 == scanf("%d", &w[i])); std::vector<int> result = find_subset(l, u, w); printf("%d\n", (int)result.size()); for (int i = 0; i < (int)result.size(); i++) printf("%d%c", result[i], " \n"[i == (int)result.size() - 1]); } #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...