# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
371222 | ja_kingy | Circus (Balkan15_CIRCUS) | C++14 | 4098 ms | 524292 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 "circus.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
vector<pii> mnstk;
vector<int> _P;
int N, M;
void init(int _N, int _M, int P[]){
N = _N;
M = _M;
_P.insert(_P.end(), P, P+N);
}
bool can_do(int k, int x, vector<int>& P) {
vector<int> mx(N+2);
priority_queue<pii> pq;
mx[x] = k;
pq.emplace(k, x);
while (pq.size()) {
pii u = pq.top(); pq.pop();
// cout << u.first << ' ' << u.second << '\n';
if (u.second == N+1) return true;
if (mx[u.second] != u.first) continue;
for (int l = u.second - 1; l >= 0 && P[u.second] - P[l] <= u.first; l--) {
int nw = P[u.second] - P[l];
if (nw > mx[l]) {
mx[l] = nw;
pq.emplace(nw, l);
}
}
for (int r = u.second + 1; r < N + 2 && P[r] - P[u.second] <= u.first; r++) {
int nw = P[r] - P[u.second];
if (nw > mx[r]) {
mx[r] = nw;
pq.emplace(nw, r);
}
}
}
return false;
}
int minLength(int D) {
vector<int> P = _P;
P.push_back(D);
P.push_back(M);
sort(P.begin(), P.end());
int x = find(P.begin(), P.end(), D) - P.begin();
int lo = 1, hi = M, mid;
while (lo != hi) {
mid = lo + hi >> 1;
if (can_do(mid, x, P)) {
hi = mid;
} else {
lo = mid + 1;
}
}
return lo;
}
Compilation message (stderr)
# | 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... |