This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Suleyman Atayew
#include "molecules.h"
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <bitset>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#define N 200010
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define mod 1000000007
#define pii pair <ll, ll>
#define sz(a) (ll)(a.size())
ll bigmod(ll a, ll b) { if(b==0)return 1; ll ret = bigmod(a, b/2); return ret * ret % mod * (b%2 ? a : 1) % mod; }
using namespace std;
ll n;
ll v[N];
ll p[N][5];
pii arr[N];
vector <int> find_subset(int l, int u, vector <int> w)
{
n = sz(w);
for(ll i = 1; i <= n; i++) arr[i] = {w[i-1], i-1};
sort(arr + 1, arr+n+1);
sort(w.begin(), w.end());
for(ll i = 1; i <= n; i++) v[i] = w[i-1], p[i][0] = p[i-1][0] + v[i];
for(ll i = n; i >= 1; i--) p[i][1] = p[i+1][1] + v[i];
for(ll i = 1; i <= n; i++) {
vector <int> ret;
if(p[i][0] >= l && p[i][0] <= u) {
for(ll h = 1; h <= i; h++) ret.pb(arr[h].ss);
return ret;
}
if(p[n-i+1][1] >= l && p[n-i+1][1] <= u) {
for(ll h = 1; h <= i; h++) ret.pb(arr[n-h+1].ss);
return ret;
}
if(p[i][0] <= l && p[n-i+1][1] >= u) {
ll sum = p[i][0];
for(ll h = i, j = n; h >= 1 && j >= n-i+1; h--, j--) {
if(sum >= l && sum <= u) {
for(ll x = h; x >= 1; x--) ret.pb(arr[x].ss);
return ret;
}
if(sum + v[j] - v[h] <= u) {
sum += v[j] - v[h];
ret.pb(arr[j].ss);
}
}
if(sum >= l && sum <= u) {
return ret;
}
}
}
vector <int> ret;
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |