# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
275914 | 2020-08-20T08:22:53 Z | 최은수(#5098) | Circus (Balkan15_CIRCUS) | C++17 | 4000 ms | 2032 KB |
#include"circus.h" #include<iostream> #include<vector> #include<algorithm> #define ep emplace #define eb emplace_back #define fi first #define se second #define all(x) (x).begin(),(x).end() using namespace std; typedef long long ll; typedef pair<int,int>pi; typedef pair<ll,ll>pl; const int inf=1e9+7; const ll INF=1e18; static int n,m; static vector<int>p; static int cal[100010]; static int mn[100010]; vector<pi>pmn,pmx; void init(int N,int M,int P[]) { n=N,m=M; for(int i=0;i<n;i++) p.eb(P[i]); sort(all(p)); p.erase(unique(all(p)),p.end()); n=p.size(); for(int i=0;i<n;i++) cal[i]=m-p[i]; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) mn[j]=inf; for(int j=0;j<n;j++) { if(j!=0) mn[j]=max(mn[j],mn[j-1]); cal[j]=min(cal[j],p[j]+mn[j]); int pos=lower_bound(all(p),p[j]+cal[j])-p.begin(); if(pos!=n) mn[pos]=-p[j]; } for(int j=0;j<n;j++) mn[j]=inf; for(int j=n;j-->0;) { if(j!=n-1) mn[j]=min(mn[j],mn[j-1]); cal[j]=min(cal[j],mn[j]-p[j]); int pos=upper_bound(all(p),p[j]-cal[j])-p.begin()-1; if(pos!=-1) mn[pos]=p[j]; } } vector<pi>p1,p2; for(int i=0;i<n;i++) { p1.eb(p[i]+cal[i],-p[i]); p2.eb(p[i]-cal[i],p[i]); } sort(all(p1)); sort(all(p2),[](const pi&x,const pi&y){return x.fi==y.fi?x.se<y.se:x.fi>y.fi;}); int pr=inf; for(pi&t:p1) if(t.se<pr) pmx.eb(t),pr=t.se; pr=inf; for(pi&t:p2) if(t.se<pr) pmn.eb(t),pr=t.se; reverse(all(pmn)); p.eb(m); return; } int minLength(int D) { int d=D; int ans=m-d; for(int i=0;i<n;i++) if(abs(d-p[i])>=cal[i]) ans=min(ans,abs(d-p[i])); return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4035 ms | 2032 KB | Time limit exceeded |
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 | Execution timed out | 4035 ms | 2032 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4035 ms | 2032 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |