This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
const int NMAX = 2e5 + 5;
int N, A[NMAX];
long long dp[NMAX];
static long long Sum (int Left, int Right)
{
if(Left > Right)
return 0LL;
return dp[Right] - dp[Left - 1];
}
vector < int > find_subset (int l, int u, vector < int > w)
{
int N = (int)w.size();
for(int i = 0; i < N; ++i)
A[i + 1] = w[i];
for(int i = 1; i <= N; ++i)
dp[i] = dp[i - 1] + 1LL * A[i];
bool Ok = false;
int Left = 1, Right = 0;
for(Left = 1, Right = 0; Left <= N; ++Left)
{
while(Sum(Left, Right) < l && Left <= N && Right <= N)
++Right;
if(Sum(Left, Right) >= l && Sum(Left, Right) <= u)
{
Ok = true;
break;
}
while(Sum(Left, Right) > u && Left <= N && Right <= N)
++Left;
if(Sum(Left, Right) >= l && Sum(Left, Right) <= u)
{
Ok = true;
break;
}
}
vector < int > Sol;
if(Ok)
{
for(int i = Left; i <= Right; ++i)
Sol.push_back(i - 1);
return Sol;
}
Left = 1;
Right = 0;
for(Left = 1, Right = 0; Left <= N && Right <= N && !Ok; ++Left)
{
for(int i = 1; i <= 16; ++i)
{
while(Sum(Left, Right) < l && Left <= N && Right <= N)
++Right;
while(Sum(Left, Right) > u && Left <= N && Right <= N)
++Left;
if(Sum(Left, Right) >= l && Sum(Left, Right) <= u)
{
Ok = true;
break;
}
}
}
if(Ok)
{
for(int i = Left; i <= Right; ++i)
Sol.push_back(i - 1);
return Sol;
}
return Sol;
}
# | 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... |