# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1051803 | fryingduc | Watching (JOI13_watching) | C++17 | 340 ms | 30520 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 "bits/stdc++.h"
using namespace std;
#define int long long
const int maxn = 2005;
int n, a[maxn], p, q;
bool check(int mid) {
vector<vector<int>> f(n + 1, vector<int>(p + 2, 1e9));
for(int i = 0; i <= p + 1; ++i) {
f[0][i] = 0;
}
int pl = 0, pr = 0;
for(int i = 1; i <= n; ++i) {
while(pl < i and a[i] - mid + 1 > a[pl]) ++pl;
while(pr < i and a[i] - mid * 2 + 1 > a[pr]) ++pr;
if(a[pl] >= a[i] - mid + 1 and pl) --pl;
if(a[pr] >= a[i] - mid * 2 + 1 and pr) --pr;
for(int j = 0; j <= p; ++j) {
f[i][j] = f[pr][j] + 1;
if(j) f[i][j] = min(f[i][j], f[pl][j - 1]);
}
}
int ans = 1e9;
for(int i = 0; i <= p; ++i) {
ans = min(ans, f[n][i]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |