# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
275875 | 2020-08-20T08:10:27 Z | 임성재(#5103) | Circus (Balkan15_CIRCUS) | C++17 | 332 ms | 6532 KB |
#include "circus.h" #include<bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(false); cin.tie(0); #define fi first #define se second #define em emplace #define eb emplace_back #define all(v) (v).begin(), (v).end() #define mp make_pair typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<int,pii> piii; const int inf = 1e9; const ll INF = 1e18; int n, m; int dp[100010]; bool chk[100010]; set<int> s; vector<int> p; priority_queue<piii, vector<piii>, greater<piii>> pQ; void init(int N, int M, int P[]){ n = N; m = M; for(int i=0; i<n; i++) p.eb(P[i]); p.eb(0); p.eb(m); sort(all(p)); p.erase(unique(all(p)), p.end()); for(int i=0; i<p.size(); i++) s.insert(p[i]); pQ.em(0, mp(m, m)); while(pQ.size()) { auto x = pQ.top(); pQ.pop(); x.se.fi = lower_bound(all(p), x.se.fi) - p.begin(); x.se.se = lower_bound(all(p), x.se.se) - p.begin(); if(chk[x.se.fi]) continue; chk[x.se.fi] = true; dp[x.se.fi] = x.fi; s.erase(p[x.se.fi]); int i = x.se.fi; int c1 = -1, c2 = -1; if(s.lower_bound(p[i] + dp[i]) != s.end()) c2 = *s.lower_bound(p[i] + dp[i]); if(s.upper_bound(p[i] - dp[i]) != s.begin()) c1 = *prev(s.upper_bound(p[i] - dp[i])); if(c1 != -1) pQ.em(p[i] - c1, mp(c1, p[i])); if(c2 != -1) pQ.em(c2 - p[i], mp(c2, p[i])); i = x.se.se; c1 = -1, c2 = -1; if(s.lower_bound(p[i] + dp[i]) != s.end()) c2 = *s.lower_bound(p[i] + dp[i]); if(s.upper_bound(p[i] - dp[i]) != s.begin()) c1 = *prev(s.upper_bound(p[i] - dp[i])); if(c1 != -1) pQ.em(p[i] - c1, mp(c1, p[i])); if(c2 != -1) pQ.em(c2 - p[i], mp(c2, p[i])); } } int minLength(int D) { int ret = m - D; for(int i=0; i<p.size(); i++) { if(abs(p[i] - D) < dp[i]) continue; ret = min(ret, abs(p[i] - D)); } return ret; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 314 ms | 6532 KB | Output is correct |
2 | Correct | 320 ms | 6256 KB | Output is correct |
3 | Correct | 310 ms | 6256 KB | Output is correct |
4 | Correct | 332 ms | 6256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Incorrect | 7 ms | 512 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Incorrect | 7 ms | 512 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 314 ms | 6532 KB | Output is correct |
2 | Correct | 320 ms | 6256 KB | Output is correct |
3 | Correct | 310 ms | 6256 KB | Output is correct |
4 | Correct | 332 ms | 6256 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Incorrect | 7 ms | 512 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 314 ms | 6532 KB | Output is correct |
2 | Correct | 320 ms | 6256 KB | Output is correct |
3 | Correct | 310 ms | 6256 KB | Output is correct |
4 | Correct | 332 ms | 6256 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Incorrect | 7 ms | 512 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |