이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
const long long INF=1e18;
long long s[1000001];
long long find_shortcut(int n, vector <int> l, vector <int> d, int c){
long long lo=0,hi=INF,kq=-1;
for (int i=1;i<n;i++)
s[i]=s[i-1]+l[i-1];
while (lo<=hi){
long long mid=(lo+hi)>>1,ch=0,mnx=-INF,mxx=INF,mny=-INF,mxy=INF;
for (int i=0;i<n;i++)
for (int j=i;j<n;j++)
if (s[j]-s[i]+d[i]+d[j]>mid){
long long sz=mid-d[i]-d[j]-c;
ch=1;
long long a=s[i],b=s[j]-sz,c=s[i],d=s[j]+sz;
a=a+b;
b=a-b*2;
c=c+d;
d=c-d*2;
mnx=max(mnx,a);
mxx=min(mxx,c);
mny=max(mny,d);
mxy=min(mxy,b);
}
if (ch){
for (int i=0;i<n;i++)
for (int j=i;j<n;j++)
if (s[j]-s[i]+d[i]+d[j]>mid){
long long x=s[i]+s[j],y=s[i]-s[j];
if (mnx<=x&&x<=mxx&&mny<=y&&y<=mxy)
ch=0;
}
}
if (!ch){
kq=mid;
hi=mid-1;
}
else
lo=mid+1;
}
return kq;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |