#include <bits/stdc++.h>
#include "molecules.h"
#define FOR(i, x, y) for (int i = x; i < y; i++)
using namespace std;
pair<int, int> a[200001];
int pref[200001];
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
FOR(i, 0, n) {
a[i].first = w[i];
a[i].second = i;
}
sort(a, a + n);
FOR(i, 0, n) pref[i + 1] = pref[i] + a[i].first;
vector<int> res;
int x = 1, y = n;
while (x < y) {
int mid = (x + y) / 2;
bool too_big = false;
FOR(i, 0, n - mid) {
int sum = pref[i + mid] - pref[i];
if (sum >= l && sum <= u) {
FOR(j, i, i + mid) res.push_back(a[j].second);
return res;
} else if (sum > u) {
too_big = true;
break;
}
}
if (too_big) y = mid - 1;
else x = mid;
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
2 ms |
384 KB |
OK (n = 12, answer = NO) |
4 |
Execution timed out |
1078 ms |
256 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |