#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <deque>
#include <cassert>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <chrono>
#include <ctime>
#include <random>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <iterator>
#include <climits>
#include "molecules.h"
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
#define INF 2001001001
#define MOD 1000000007
int L,U,N,W[200001];
ll sum[200001];
bool used[200001];
map<int,deque<int>>ind;
vector<int> find_subset(int L, int U, vector<int>w) {
vector<int>ans;
N=w.size();
for (int i=1;i<=N;i++){
W[i]=w[i-1];
ind[W[i]].push_back(i);
}
sort(W+1,W+N+1);
for (int i=1;i<=N;i++)
sum[i]=sum[i-1]+W[i];
int len=-1;
for (int i=1;i<=N;i++){
if (sum[i]<=U && sum[N]-sum[N-i]>=L){
len=i;
break;
}
}
if (len==-1)
return ans;
ll cur=sum[N]-sum[N-len];
deque<int>q;
int smallest=1;
for (int i=N;i>N-len;i--){
q.push_back(i);
used[i]=true;
}
while (!(cur>=L && cur<=U)){
int x=q[0];
q.pop_front();
cur-=W[x];
cur+=W[smallest];
q.push_back(smallest);
assert(!used[smallest]);
used[smallest]=true;
smallest++;
}
assert(cur>=L && cur<=U);
assert((int)q.size()==len);
ll cur2=0;
for (int i=0;i<len;i++){
ans.push_back(ind[W[q[i]]][0]);
cur2+=W[q[i]];
ind[W[q[i]]].pop_front();
}
assert(cur2>=L && cur2<=U);
return ans;
}
# |
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 |
Incorrect |
2 ms |
376 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
2 ms |
376 KB |
OK (n = 12, answer = NO) |
5 |
Incorrect |
2 ms |
376 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 |
376 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
376 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
376 KB |
Integer 1 violates the range [0, 0] |
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 |
Incorrect |
2 ms |
376 KB |
Integer 1 violates the range [0, 0] |
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 |
Incorrect |
2 ms |
376 KB |
Integer 1 violates the range [0, 0] |
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 |
Incorrect |
2 ms |
376 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |