//by szh
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
#include "shortcut.h"
const int maxn = 3e3+10;
ll pos[maxn];
ll a[maxn];
int n,C;
deque <int> q;
bool check(ll k) {
ll A = 1e18, B = -1e18;
ll mx1 = 1e18, mn1 = -1e18, mx2 = 1e18, mn2 = -1e18;
q.clear();
rep(j,0,n) {
if (pos[j] + a[j] - A > k) {
while (!q.empty() and pos[j] + a[j] - (pos[q.front()] - a[q.front()]) > k) {
B = max(B,pos[q.front()] + a[q.front()]);
q.pop_front();
}
mx1 = min(mx1,k + pos[j] - a[j] + A - C);
mn1 = max(mn1,pos[j] + a[j] + B - k + C);
mx2 = min(mx2,k + pos[j] - a[j] - B - C);
mn2 = max(mn2,pos[j] + a[j] - A - k + C);
}
if (mn1 > mx1) return false;
if (mn2 > mx2) return false;
while (!q.empty() and pos[q.back()] - a[q.back()] >= pos[j] - a[j]) q.pop_back();
A = min(A,pos[j] - a[j]);
q.pb(j);
}
int y = 0, z1 = n-1, z2 = n-1;
while (y<n) {
while (z2>y and pos[y] + pos[z2] > mx1) z2--;
if (z2==y) break;
while (z1-1>=0 and pos[y] + pos[z1-1] >= mx1) z1--;
if (pos[z2] - pos[y] < mn2 or pos[max(z1,y+1)] - pos[y] > mx2) y++;
else return true;
}
return false;
}
long long find_shortcut(int N, std::vector<int> L, std::vector<int> d, int c)
{
n = N; C=c;
pos[0] = 0;
rep(i,1,n) pos[i] = pos[i-1] + L[i-1];
rep(i,0,n) a[i] = d[i];
ll l = 0,r = 1e16;
while (l<r) {
ll mid = (l+r)/2;
if (check(mid)) r = mid;
else l = mid+1;
}
return l;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
1 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
304 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
1 ms |
212 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
1 ms |
212 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
1 ms |
212 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
308 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
0 ms |
300 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
1 ms |
212 KB |
n = 10, 438 is a correct answer |
26 |
Correct |
1 ms |
304 KB |
n = 10, 206 is a correct answer |
27 |
Correct |
1 ms |
212 KB |
n = 10, 636 is a correct answer |
28 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 2399 vs contestant 2406 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
1 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
304 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
1 ms |
212 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
1 ms |
212 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
1 ms |
212 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
308 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
0 ms |
300 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
1 ms |
212 KB |
n = 10, 438 is a correct answer |
26 |
Correct |
1 ms |
304 KB |
n = 10, 206 is a correct answer |
27 |
Correct |
1 ms |
212 KB |
n = 10, 636 is a correct answer |
28 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 2399 vs contestant 2406 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
1 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
304 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
1 ms |
212 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
1 ms |
212 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
1 ms |
212 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
308 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
0 ms |
300 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
1 ms |
212 KB |
n = 10, 438 is a correct answer |
26 |
Correct |
1 ms |
304 KB |
n = 10, 206 is a correct answer |
27 |
Correct |
1 ms |
212 KB |
n = 10, 636 is a correct answer |
28 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 2399 vs contestant 2406 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
1 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
304 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
1 ms |
212 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
1 ms |
212 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
1 ms |
212 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
308 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
0 ms |
300 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
1 ms |
212 KB |
n = 10, 438 is a correct answer |
26 |
Correct |
1 ms |
304 KB |
n = 10, 206 is a correct answer |
27 |
Correct |
1 ms |
212 KB |
n = 10, 636 is a correct answer |
28 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 2399 vs contestant 2406 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
1 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
304 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
1 ms |
212 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
1 ms |
212 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
1 ms |
212 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
308 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
0 ms |
300 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
1 ms |
212 KB |
n = 10, 438 is a correct answer |
26 |
Correct |
1 ms |
304 KB |
n = 10, 206 is a correct answer |
27 |
Correct |
1 ms |
212 KB |
n = 10, 636 is a correct answer |
28 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 2399 vs contestant 2406 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
1 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
304 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
1 ms |
212 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
1 ms |
212 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
1 ms |
212 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
308 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
0 ms |
300 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
1 ms |
212 KB |
n = 10, 438 is a correct answer |
26 |
Correct |
1 ms |
304 KB |
n = 10, 206 is a correct answer |
27 |
Correct |
1 ms |
212 KB |
n = 10, 636 is a correct answer |
28 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 2399 vs contestant 2406 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
1 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
304 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
1 ms |
212 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
1 ms |
212 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
1 ms |
212 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
308 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
0 ms |
300 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
1 ms |
212 KB |
n = 10, 438 is a correct answer |
26 |
Correct |
1 ms |
304 KB |
n = 10, 206 is a correct answer |
27 |
Correct |
1 ms |
212 KB |
n = 10, 636 is a correct answer |
28 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 2399 vs contestant 2406 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
0 ms |
212 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
0 ms |
212 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
0 ms |
212 KB |
n = 3, 4 is a correct answer |
5 |
Correct |
1 ms |
212 KB |
n = 2, 62 is a correct answer |
6 |
Correct |
1 ms |
212 KB |
n = 2, 3 is a correct answer |
7 |
Correct |
0 ms |
212 KB |
n = 3, 29 is a correct answer |
8 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
9 |
Correct |
0 ms |
212 KB |
n = 2, 3 is a correct answer |
10 |
Correct |
0 ms |
212 KB |
n = 2, 2000000001 is a correct answer |
11 |
Correct |
0 ms |
212 KB |
n = 2, 3000000000 is a correct answer |
12 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
13 |
Correct |
1 ms |
212 KB |
n = 3, 3000000000 is a correct answer |
14 |
Correct |
0 ms |
212 KB |
n = 4, 3000000001 is a correct answer |
15 |
Correct |
0 ms |
212 KB |
n = 4, 4000000000 is a correct answer |
16 |
Correct |
1 ms |
212 KB |
n = 5, 4000000000 is a correct answer |
17 |
Correct |
1 ms |
212 KB |
n = 10, 1000000343 is a correct answer |
18 |
Correct |
0 ms |
212 KB |
n = 10, 3189 is a correct answer |
19 |
Correct |
1 ms |
304 KB |
n = 10, 7000000000 is a correct answer |
20 |
Correct |
1 ms |
212 KB |
n = 5, 12 is a correct answer |
21 |
Correct |
1 ms |
212 KB |
n = 5, 25 is a correct answer |
22 |
Correct |
1 ms |
212 KB |
n = 2, 122 is a correct answer |
23 |
Correct |
1 ms |
308 KB |
n = 10, 117 is a correct answer |
24 |
Correct |
0 ms |
300 KB |
n = 10, 336 is a correct answer |
25 |
Correct |
1 ms |
212 KB |
n = 10, 438 is a correct answer |
26 |
Correct |
1 ms |
304 KB |
n = 10, 206 is a correct answer |
27 |
Correct |
1 ms |
212 KB |
n = 10, 636 is a correct answer |
28 |
Incorrect |
1 ms |
212 KB |
n = 4, incorrect answer: jury 2399 vs contestant 2406 |
29 |
Halted |
0 ms |
0 KB |
- |