# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
474691 | RafaelSus | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 292 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
std::vector<int> find_subset(int l, int r, std::vector<int> a){
std::sort(a.begin(), a.end());
int pl = 0;
int pr = 1;
long long sum = a[0];
bool ok = true;
while(true){
if (pl >= a.size() and pr >= a.size()){
ok = false;
break;
}
if (sum >= l and sum <= r){
break;
}else if (sum < l){
pr++;
sum += a[pr - 1];
}else if (sum > r){
sum -= a[pl];
pl++;
}
}
if (ok) {
std::vector<int> answ;
for (int i = pl; i < pr; i++)
answ.push_back(i);
return answ;
}else {
std::vector<int> answ;
return answ;
}
}
#ifdef TEST
int main(){
int l, r;
unsigned int n;
std::cin >> l >> r >> n;
std::vector<int> a(n);
for (int i = 0; i < n; i++)
std::cin >> a[i];
std::vector<int> answ = find_subset(l, r, a);
for (int i = 0; i < answ.size(); i++){
std::cout << answ[i] << ' ';
}
std::cout << '\n';
}
#endif
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |