| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 670837 | finn__ | Circus (Balkan15_CIRCUS) | C++17 | 19 ms | 2260 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "circus.h"
#include <bits/stdc++.h>
using namespace std;
vector<int64_t> p;
vector<int64_t> dp;
int64_t m;
int64_t min_height(int64_t d)
{
int64_t a = 0, b = 1e18;
while (a < b)
{
int64_t mid = (a + b) / 2;
size_t i = upper_bound(p.begin(), p.end(), d) - p.begin() - 1;
bool possible = 0;
while (i < p.size() && p[i] <= d + mid && !possible)
{
if (dp[i] <= p[i] - d)
possible = 1;
i++;
}
if (possible)
b = mid;
else
a = mid + 1;
}
return a;
}
void init(int N, int M, int P[])
{
m = M;
p = vector<int64_t>(N + 1);
dp = vector<int64_t>(N + 1);
p[N] = M;
dp[N] = 0;
copy(P, P + N, p.begin());
sort(p.begin(), p.end());
for (size_t i = 0; i < N + 1; i++)
dp[i] = max((int64_t)0, M - p[i]);
priority_queue<pair<int64_t, unsigned>, vector<pair<int64_t, unsigned>>, greater<pair<int64_t, unsigned>>> q;
q.push({0, lower_bound(p.begin(), p.end(), M) - p.begin()});
while (!q.empty())
{
auto const [h, u] = q.top();
q.pop();
if (h != dp[u])
continue;
size_t i = upper_bound(p.begin(), p.end(), p[u] + h) - p.begin();
while (i < p.size())
{
if (p[i] - p[u] < dp[i])
{
dp[i] = p[i] - p[u];
q.push({dp[i], i});
}
i++;
}
i = upper_bound(p.begin(), p.end(), p[u] - h) - p.begin() - 1;
while (i <= N)
{
if (p[u] - p[i] < dp[i])
{
dp[i] = p[u] - p[i];
q.push({dp[i], i});
}
i--;
}
}
}
int minLength(int D)
{
int64_t min_h = max((int64_t)0, m - D);
for (size_t i = 0; i < dp.size(); i++)
if (dp[i] <= abs(D - p[i]))
min_h = min(min_h, abs(D - p[i]));
return min_h;
}
컴파일 시 표준 에러 (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... | ||||
