#pragma GCC optimize("O3")
#include "shortcut.h"
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<50);
const int inf=(1<<30);
const int nmax=3e3+50;
const int mod=1e9+7;
using namespace std;
ll p[nmax],v[nmax],cst;
int n;
int ok(ll x)
{
ll mn1=llinf,mn2=llinf,mx1=-llinf,mx2=-llinf,v1,v2;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(v[i]+v[j]+p[j]-p[i]<=x)continue;
ll d=x-v[i]-v[j]-cst;
mx1=max(mx1,p[i]+p[j]-d);
mx2=max(mx2,p[j]-p[i]-d);
mn1=min(mn1,p[i]+p[j]+d);
mn2=min(mn2,p[j]-p[i]+d);
}
}
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
v1=p[i]+p[j],v2=p[j]-p[i];
if(mn1<=v1 && v1<=mx1 && mn2<=v2 && v2<=mx2)return 1;
}
}
return 0;
}
ll find_shortcut(int N,vector<int>L,vector<int>d,int c)
{
n=N,cst=c;
for(int i=0;i<n-1;i++)p[i+1]=p[i]+L[i];
for(int i=0;i<n;i++)v[i]=d[i];
ll l=0,r=llinf,mid,ans=llinf;
while(l<=r)
{
mid=(l+r)/2;
if(ok(mid))
{
ans=mid;
r=mid-1;
}
else l=mid+1;
}
return ans;
}
/*int main()
{
//freopen("sol.in","r",stdin);
//freopen("sol.out","w",stdout);
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
return 0;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
n = 4, incorrect answer: jury 80 vs contestant 1125899906842624 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
n = 4, incorrect answer: jury 80 vs contestant 1125899906842624 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
n = 4, incorrect answer: jury 80 vs contestant 1125899906842624 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
n = 4, incorrect answer: jury 80 vs contestant 1125899906842624 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
n = 4, incorrect answer: jury 80 vs contestant 1125899906842624 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
n = 4, incorrect answer: jury 80 vs contestant 1125899906842624 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
n = 4, incorrect answer: jury 80 vs contestant 1125899906842624 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
n = 4, incorrect answer: jury 80 vs contestant 1125899906842624 |
2 |
Halted |
0 ms |
0 KB |
- |