#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.push_back({w[i], 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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
380 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Contestant can not find answer, jury can |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
380 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
380 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
380 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
380 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |