# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
278742 | 2020-08-21T17:44:19 Z | arnold518 | Circus (Balkan15_CIRCUS) | C++14 | 112 ms | 3072 KB |
#include "circus.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 3e5; const int INF = 2e9; int N, M, P[MAXN+10]; int dist[MAXN+10]; struct Queue { int u, w; bool operator < (const Queue &p) const { return w>p.w; } }; void init(int _N, int _M, int _P[]) { N=_N; M=_M; for(int i=1; i<=N; i++) P[i]=_P[i-1]; sort(P+1, P+N+1); N=unique(P+1, P+N+1)-P-1; P[0]=M; for(int i=0; i<=3*N; i++) dist[i]=INF; priority_queue<Queue> PQ; PQ.push({2*N, M-P[N]}); dist[0]=0; while(!PQ.empty()) { Queue now=PQ.top(); PQ.pop(); if(dist[now.u]<=now.w) continue; dist[now.u]=now.w; if(now.u<=N) { int t=upper_bound(P+1, P+N+1, P[now.u]-now.w)-P-1; if(t!=0) PQ.push({N+t, P[now.u]-P[t]}); t=lower_bound(P+1, P+N+1, P[now.u]+now.w)-P; if(t!=N+1) PQ.push({N*2+t, P[t]-P[now.u]}); } else if(now.u<=2*N) { PQ.push({now.u-N, now.w}); if(now.u==N+1) continue; PQ.push({now.u-1, now.w+P[now.u-N]-P[now.u-N-1]}); } else { PQ.push({now.u-2*N, now.w}); if(now.u==3*N) continue; PQ.push({now.u+1, P[now.u+1-2*N]-P[now.u-2*N]}); } } } int minLength(int D) { int ans=M-D; for(int i=1; i<=N; i++) if(dist[i]<=abs(P[i]-D)) ans=min(ans, abs(P[i]-D)); return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 112 ms | 3072 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 112 ms | 3072 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 112 ms | 3072 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |