#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
pair<ll,int> p[200001];
ll pr[200001];
ll su[200001];
vector<int> find_subset(int l,int u,vector<int> w){
int N=w.size();
for(int i=0;i<N;i++){
p[i].f=(ll)w[i];
p[i].s=i;
}
sort(p,p+N);
vector<int> sol;
int j=N;
int s=0;
int s1=0;
for(int i=0;i<N;i++){
s+=p[i].f;
s1+=p[N-i-1].f;
pr[i]=s;
su[N-i-1]=s1;
if(s1>u&&j==N)j=N-i;
}
if(su[j]>=l&&su[j]<=u){
for(int i=N-1;i>=j;i--)sol.push_back(p[i].s);
return sol;
}
for(int i=0;i<N;i++){
for(;j<N&&su[j]+pr[i]>u;j++){}
if(pr[i]+su[j]>=l&&su[j]+pr[i]<=u){
for(int k=N-1;k>=j;k--)sol.push_back(p[k].s);
for(int k=0;k<=i;i++)sol.push_back(p[k].s);
return sol;
}
}
return sol;
}
# |
Verdict |
Execution time |
Memory |
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 |
Runtime error |
104 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
94 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
Runtime error |
104 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
Runtime error |
104 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
Runtime error |
104 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
Runtime error |
104 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |