# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
24843 | nibnalin | Watching (JOI13_watching) | C++14 | 333 ms | 17744 KiB |
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 <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn = int(2e3)+5, inf = int(1e9)+5;
int n, p, q, A[maxn], nex[maxn][2], memo[maxn][maxn];
bool f(int w)
{
for(int idx = n-1;idx >= 0;idx--)
{
nex[idx][0] = int(lower_bound(A, A+n, A[idx]+w)-A);
nex[idx][1] = int(lower_bound(A, A+n, A[idx]+min(inf, 2*w))-A);
for(int pp = 0;pp <= p;pp++)
{
memo[idx][pp] = inf;
if(pp) memo[idx][pp] = min(memo[idx][pp], memo[nex[idx][0]][pp-1]);
memo[idx][pp] = min(memo[idx][pp], memo[nex[idx][1]][pp]+1);
}
}
//cout << w << " " << memo[0][p] << "\n";
return (memo[0][p] <= q);
}
int main(void)
{
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |