#include "molecules.h"
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
vector<int>find_subset(int l, int r, vector<int>a)
{
vector<pii>v;
for(int i = 0; i < sz(a); i++)
v.pb({a[i], i + 1});
sort(all(v));
vector<int>pref(sz(v), 0), suf(sz(v), 0);
pref[0] = v[0].x;
suf[sz(v) - 1] = v.back().x;
for(int i = 1; i < sz(v); i++)
pref[i] = pref[i - 1] + v[i].x;
for(int i = sz(v) - 2; i >= 0; i--)
suf[i] = suf[i + 1] + v[i].x;
for(int siz = 1; siz <= sz(v); siz++)
{
if(pref[siz - 1] <= r && suf[sz(v) - siz] >= l)
{
ll sum = 0;
for(int i = 0; i < sz(v); i++)
{
sum += v[i].x;
if(i >= siz)
sum -= v[i - siz].x;
if(i >= siz - 1 && sum >= l && sum <= r)
{
vector<int>ans;
for(int j = i - siz + 1; j <= i; j++)
ans.pb(v[j].y);
return ans;
}
}
}
}
return {};
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
2 ms |
384 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = NO) |
5 |
Incorrect |
2 ms |
384 KB |
sum of weights should be in [290..300] but it is 301 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |