# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
590744 | 2022-07-06T10:04:24 Z | DAleksa | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 212 KB |
#include <bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int r, vector<int> a) { vector<int> res; int n = a.size(); vector<int> order(n); iota(order.begin(), order.end(), 0); sort(order.begin(), order.end(), [&](int i, int j) { return a[i] < a[j]; }); vector<long long> prefix(n); prefix[0] = a[order[0]]; for(int i = 1; i < n; i++) prefix[i] = prefix[i - 1] + a[order[i]]; int len = -1; for(int i = 0; i < n; i++) cout << prefix[i] << " "; cout << "\n"; for(int i = 0; i < n; i++) { if(prefix[i] <= r && prefix[n - 1] - (n - i - 2 >= 0 ? prefix[n - i - 2] : 0) >= l) { len = i + 1; break; } } if(len == -1) return res; if(l <= prefix[len - 1] && prefix[len - 1] <= r) { for(int i = 0; i < len; i++) res.push_back(order[i]); return res; } for(int i = 0; i + len < n; i++) { if(l <= prefix[i + len] - prefix[i] && prefix[i + len] - prefix[i] <= r) { for(int j = i + 1; j <= i + len; j++) res.push_back(order[j]); return res; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Secret is incorrect! |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Secret is incorrect! |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Secret is incorrect! |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Secret is incorrect! |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Secret is incorrect! |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Secret is incorrect! |
2 | Halted | 0 ms | 0 KB | - |