#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
struct mol{
int loc, val;
bool operator<(const mol& rhs) const{
return val <= rhs.val;
}
};
vector<mol> v;
vector<int> s;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int i, n = w.size();
mol tmp;
for( i = 0; i < n; i++){
tmp.loc = i;
tmp.val = w[i];
v.push_back(tmp);
}
sort(v.begin(), v.end());
s.push_back(0);
for(i = 0; i < n; i++){
s.push_back(s[i] + v[i].val);
}
for( i = 1;i <=n ; i++){
if(s[i ] > u){
break;
}
if(s[n] - s[ n - i] >= l){
break;
}
}
if(s[i] > u || i == n + 1){
return std::vector<int>(0);
}
vector<int> ans;
int j;
if(n == i){
for(i = i - 1; i >= 0 ; i--){
ans.push_back(v[i].loc);
}
return ans;
}
for(j = 1; j + i<= n; j++){
if(s[j + i] - s[j] > u){
ans.push_back(v[j - 1].loc);
i--;
u -= v[j - 1].val;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
356 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
560 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
3 ms |
560 KB |
OK (n = 2, answer = YES) |
5 |
Incorrect |
2 ms |
560 KB |
Contestant can not find answer, jury can |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
560 KB |
sum of weights should be in [302..304] but it is 100 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
356 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
560 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
3 ms |
560 KB |
OK (n = 2, answer = YES) |
5 |
Incorrect |
2 ms |
560 KB |
Contestant can not find answer, jury can |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
356 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
560 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
3 ms |
560 KB |
OK (n = 2, answer = YES) |
5 |
Incorrect |
2 ms |
560 KB |
Contestant can not find answer, jury can |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
356 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
560 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
3 ms |
560 KB |
OK (n = 2, answer = YES) |
5 |
Incorrect |
2 ms |
560 KB |
Contestant can not find answer, jury can |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
3 ms |
356 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
4 ms |
560 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
3 ms |
560 KB |
OK (n = 2, answer = YES) |
5 |
Incorrect |
2 ms |
560 KB |
Contestant can not find answer, jury can |
6 |
Halted |
0 ms |
0 KB |
- |