#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
long long prefix[N], suffix[N];
long long find_sum(int l, int r){
if(l == 0){
return prefix[r];
}
return prefix[r] - prefix[l - 1];
}
vector<int> find_subset(int l, int r, vector<int> w){
vector<int> ans;
int n = (int)w.size();
vector<pair<long long, int> > a;
for(int i = 0; i < n; i++){
a[i].first = w[i];
a[i].second = i;
}
sort(a.begin(), a.end());
prefix[0] = a[0].second;
for(int i = 1; i < n; i++){
prefix[i] = prefix[i - 1] + (long long)a[i].second;
}
for(int i = 1; i <= n; i++){
if(find_sum(0, i - 1) > r || find_sum(n - i, n - 1) < l){
continue;
}
for(int j = 0; j <= n - i; j++){
long long sum = find_sum(j, j + i - 1);
if(l <= sum && sum <= r){
for(int k = 0; k < i; k++){
ans.push_back(j + k);
}
return ans;
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |