#include <bits/stdc++.h>
#include "shortcut.h"
using namespace std;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define y1 asjfkgasj
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define flsh '\n'<<flush
#define mp make_pair
#define mt make_tuple
#define sz size
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vi vector<int>
#define vll vector<long long>
#define deb(x) cout<< #x <<'='<< x <<flsh;
#define iii int,int,int
#define ull unsigned long long
#define intt long long
#define ld long double
#define dd double
#define OK cout<<"OK\n"<<flsh;
#define setpre(x) fixed<<setprecision(x)
#define mmset(x,y) memset(x,y,sizeof(x))
intt pref[3001],suf[3001],ans,res,mx[3001][3001],L[3001];
long long find_shortcut(int n, vector<int> l, vector<int> d, int c)
{
pref[0]=d[0];
for(int i=1;i<n;i++)
{
pref[i]=max(pref[i-1]+l[i-1],1LL*d[i]);
ans=max(ans,pref[i-1]+l[i-1]+d[i]);
}
//ans=999999;
suf[n-1]=d[n-1];
for(int i=n-2;i>=0;i--)
{
suf[i]=max(suf[i+1]+l[i],1LL*d[i]);
ans=max(ans,suf[i+1]+l[i]+d[i]);
}
//deb(ans);
l.pb(0);
for(int i=n-1;i>=0;i--)
l[i]=l[i-1];
L[0]=0;
for(int i=1;i<n;i++)
L[i]=L[i-1]+l[i];
for(int i=0;i<n;i++)
{
mx[i][i]=d[i];
for(int j=i+1;j<n;j++)
{
//mx[i][j]=mx[j][i]=mx[i][i];
for(int k=i;k<j;k++)
mx[i][j]=mx[j][i]=max(max(1LL*d[k]+(L[j]-L[k])+d[j],mx[i][k]),mx[i][j]);
}
}
/*
for(int i=0;i<n;i++) cout<<pref[i]<<" \n"[i+1==n];
for(int i=0;i<n;i++) cout<<suf[i]<<" \n"[i+1==n];
for(int i=0;i<n;i++) cout<<L[i]<<" \n"[i+1==n];
cout<<endl;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cout<<mx[i][j]<<" \n"[j+1==n];
cout<<endl;
//*/
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
{
res=0;
res=max(pref[i]+suf[j]+c,max(mx[0][i],mx[j][n-1]));
if(j-i>1) res=max(res,mx[i+1][j-1]);
//cout<<i<<' '<<j<<"->"<<res<<endl;
for(int k=i+1;k<j;k++)
res=max(res,max(min(1LL*L[k]-L[i],1LL*L[j]-L[k]+c)+pref[i],min(1LL*L[k]-L[i]+c,1LL*L[j]-L[k])+suf[j])+d[k]);
ans=min(res,ans);
//cout<<i<<' '<<j<<"->"<<res<<endl;
}
//if(n==4 and ans==3000000000LL) ans++;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
2 ms |
376 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
2 ms |
376 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
2 ms |
376 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
2 ms |
376 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
2 ms |
380 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
2 ms |
376 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
2 ms |
376 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
2 ms |
376 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
2 ms |
376 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
2 ms |
376 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
2 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
2 ms |
376 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
2 ms |
376 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
2 ms |
376 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
2 ms |
376 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
2 ms |
380 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
2 ms |
380 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
2 ms |
480 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
2 ms |
376 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
2 ms |
376 KB |
n = 10, 438 is a correct answer |
26 |
Incorrect |
2 ms |
376 KB |
n = 10, incorrect answer: jury 206 vs contestant 217 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
2 ms |
376 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
2 ms |
376 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
2 ms |
376 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
2 ms |
376 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
2 ms |
380 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
2 ms |
376 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
2 ms |
376 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
2 ms |
376 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
2 ms |
376 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
2 ms |
376 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
2 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
2 ms |
376 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
2 ms |
376 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
2 ms |
376 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
2 ms |
376 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
2 ms |
380 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
2 ms |
380 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
2 ms |
480 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
2 ms |
376 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
2 ms |
376 KB |
n = 10, 438 is a correct answer |
26 |
Incorrect |
2 ms |
376 KB |
n = 10, incorrect answer: jury 206 vs contestant 217 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
2 ms |
376 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
2 ms |
376 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
2 ms |
376 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
2 ms |
376 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
2 ms |
380 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
2 ms |
376 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
2 ms |
376 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
2 ms |
376 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
2 ms |
376 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
2 ms |
376 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
2 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
2 ms |
376 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
2 ms |
376 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
2 ms |
376 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
2 ms |
376 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
2 ms |
380 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
2 ms |
380 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
2 ms |
480 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
2 ms |
376 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
2 ms |
376 KB |
n = 10, 438 is a correct answer |
26 |
Incorrect |
2 ms |
376 KB |
n = 10, incorrect answer: jury 206 vs contestant 217 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
2 ms |
376 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
2 ms |
376 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
2 ms |
376 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
2 ms |
376 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
2 ms |
380 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
2 ms |
376 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
2 ms |
376 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
2 ms |
376 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
2 ms |
376 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
2 ms |
376 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
2 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
2 ms |
376 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
2 ms |
376 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
2 ms |
376 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
2 ms |
376 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
2 ms |
380 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
2 ms |
380 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
2 ms |
480 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
2 ms |
376 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
2 ms |
376 KB |
n = 10, 438 is a correct answer |
26 |
Incorrect |
2 ms |
376 KB |
n = 10, incorrect answer: jury 206 vs contestant 217 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
2 ms |
376 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
2 ms |
376 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
2 ms |
376 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
2 ms |
376 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
2 ms |
380 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
2 ms |
376 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
2 ms |
376 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
2 ms |
376 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
2 ms |
376 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
2 ms |
376 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
2 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
2 ms |
376 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
2 ms |
376 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
2 ms |
376 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
2 ms |
376 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
2 ms |
380 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
2 ms |
380 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
2 ms |
480 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
2 ms |
376 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
2 ms |
376 KB |
n = 10, 438 is a correct answer |
26 |
Incorrect |
2 ms |
376 KB |
n = 10, incorrect answer: jury 206 vs contestant 217 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
2 ms |
376 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
2 ms |
376 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
2 ms |
376 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
2 ms |
376 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
2 ms |
380 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
2 ms |
376 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
2 ms |
376 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
2 ms |
376 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
2 ms |
376 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
2 ms |
376 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
2 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
2 ms |
376 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
2 ms |
376 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
2 ms |
376 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
2 ms |
376 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
2 ms |
380 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
2 ms |
380 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
2 ms |
480 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
2 ms |
376 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
2 ms |
376 KB |
n = 10, 438 is a correct answer |
26 |
Incorrect |
2 ms |
376 KB |
n = 10, incorrect answer: jury 206 vs contestant 217 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
2 ms |
376 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
2 ms |
376 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
2 ms |
376 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
2 ms |
376 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
2 ms |
380 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
2 ms |
376 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
2 ms |
376 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
2 ms |
376 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
2 ms |
376 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
2 ms |
376 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
2 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
2 ms |
376 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
2 ms |
376 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
2 ms |
376 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
2 ms |
376 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
2 ms |
380 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
2 ms |
380 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
2 ms |
480 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
2 ms |
376 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
2 ms |
376 KB |
n = 10, 438 is a correct answer |
26 |
Incorrect |
2 ms |
376 KB |
n = 10, incorrect answer: jury 206 vs contestant 217 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
2 ms |
376 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
2 ms |
376 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
2 ms |
376 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
2 ms |
376 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
2 ms |
380 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
2 ms |
376 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
2 ms |
376 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
2 ms |
376 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
2 ms |
376 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
2 ms |
376 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
2 ms |
376 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
2 ms |
376 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
2 ms |
376 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
2 ms |
376 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
2 ms |
376 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
2 ms |
376 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
2 ms |
376 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
2 ms |
380 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
2 ms |
380 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
2 ms |
480 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
2 ms |
376 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
2 ms |
376 KB |
n = 10, 438 is a correct answer |
26 |
Incorrect |
2 ms |
376 KB |
n = 10, incorrect answer: jury 206 vs contestant 217 |
27 |
Halted |
0 ms |
0 KB |
- |