# include <bits/stdc++.h>
# define FILE
using namespace std;
vector < int > find_subset( int l, int u, vector < int > w ){
int n = w.size();
pair < int, int > pr[n];
for( int i = 0; i < n; i ++ )
pr[i] = make_pair( w[i], i );
sort( pr, pr+n );
int ll = 0, rr = 1;
int sum = pr[ll].first;
vector < int > answers;
while( rr < n ){
if( sum > u ){
sum -= pr[ll].first;
ll++;
if( ll > rr ){
return answers;
}
}
if( l <= sum && sum <= u ){
for( int i = ll; i < rr; i ++ ){
answers.push_back( pr[i].second );
}
return answers;
}
sum += pr[rr++].first;
}
if( sum > u ){
sum -= pr[ll].first;
ll++;
}
for( int i = ll; i < rr; i ++ )
answers.push_back( i );
return answers;
}
/*
int main(){
# ifdef FILE
freopen( "input.txt", "r", stdin );
freopen( "output.txt", "w", stdout );
# endif
int n, l, u;
cin >> n >> l >> u;
vector < int > w(n);
for( int i = 0; i < n; i ++ ){
cin >> w[i];
}
vector < int > ans = find_subset( l, u, w );
for( auto c: ans ){
cout << c << ' ';
}cout << endl;
return 0;
}
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
sum of weights should be in [10..12] but it is 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
3 |
Incorrect |
2 ms |
376 KB |
sum of weights should be in [307..317] but it is 306 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
sum of weights should be in [10..12] but it is 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
sum of weights should be in [10..12] but it is 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
sum of weights should be in [10..12] but it is 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
sum of weights should be in [10..12] but it is 9 |
2 |
Halted |
0 ms |
0 KB |
- |