#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=2e5+9,M=2e18+9,mod=1e9+7;
bool vis[N];
pair<ll,ll>p;
vector<ll>v[N];
ll a[N],n,x,y,z;
priority_queue<pair<ll,ll>>q;
void init(int m,vector<int>h)
{
n=m;
for(ll i=0;i<n;++i)a[i]=h[i];
for(ll i=0;i<n;++i)
{
for(ll j=i-1;j>=0;--j)
{
if(a[j]>a[i])
{
v[i].push_back(j);
break;
}
}
for(ll j=i+1;j<n;++j)
{
if(a[j]>a[i])
{
v[i].push_back(j);
break;
}
}
}
}
int minimum_jumps(int A, int B, int C, int D)
{
x=-1;
vector<ll>d(n,M);
for(ll i=A;i<=B;++i)
{
d[i]=0;
q.push({0,i});
while(q.size())
{
y=q.top().second;
q.pop();
if(C<=y && y<=D)
{
x=(x==-1?d[y]:min(x,d[y]));
continue;
}
for(auto j:v[y])
{
if(d[j]>d[y]+1)
{
d[j]=d[y]+1;
q.push({-d[j],j});
}
}
}
}
return x;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
2 ms |
6488 KB |
Output is correct |
3 |
Execution timed out |
4057 ms |
12772 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6584 KB |
Output is correct |
3 |
Correct |
2 ms |
6488 KB |
Output is correct |
4 |
Correct |
2 ms |
6488 KB |
Output is correct |
5 |
Correct |
2 ms |
6488 KB |
Output is correct |
6 |
Correct |
2 ms |
6488 KB |
Output is correct |
7 |
Correct |
2 ms |
6488 KB |
Output is correct |
8 |
Correct |
3 ms |
6488 KB |
Output is correct |
9 |
Correct |
2 ms |
6488 KB |
Output is correct |
10 |
Correct |
3 ms |
6488 KB |
Output is correct |
11 |
Correct |
14 ms |
6488 KB |
Output is correct |
12 |
Correct |
13 ms |
6488 KB |
Output is correct |
13 |
Correct |
10 ms |
6488 KB |
Output is correct |
14 |
Correct |
4 ms |
6488 KB |
Output is correct |
15 |
Correct |
5 ms |
6488 KB |
Output is correct |
16 |
Correct |
3 ms |
6488 KB |
Output is correct |
17 |
Correct |
4 ms |
6488 KB |
Output is correct |
18 |
Correct |
1 ms |
6488 KB |
Output is correct |
19 |
Correct |
1 ms |
6488 KB |
Output is correct |
20 |
Correct |
3 ms |
6484 KB |
Output is correct |
21 |
Correct |
11 ms |
6488 KB |
Output is correct |
22 |
Correct |
4 ms |
6488 KB |
Output is correct |
23 |
Correct |
5 ms |
6488 KB |
Output is correct |
24 |
Correct |
3 ms |
6488 KB |
Output is correct |
25 |
Correct |
1 ms |
6488 KB |
Output is correct |
26 |
Correct |
1 ms |
6488 KB |
Output is correct |
27 |
Correct |
2 ms |
6488 KB |
Output is correct |
28 |
Correct |
3 ms |
6488 KB |
Output is correct |
29 |
Correct |
3 ms |
6488 KB |
Output is correct |
30 |
Correct |
2 ms |
6488 KB |
Output is correct |
31 |
Correct |
2 ms |
6488 KB |
Output is correct |
32 |
Correct |
3 ms |
6488 KB |
Output is correct |
33 |
Correct |
1 ms |
6488 KB |
Output is correct |
34 |
Correct |
1 ms |
6488 KB |
Output is correct |
35 |
Correct |
1 ms |
6488 KB |
Output is correct |
36 |
Correct |
2 ms |
6488 KB |
Output is correct |
37 |
Correct |
2 ms |
6488 KB |
Output is correct |
38 |
Correct |
1 ms |
6488 KB |
Output is correct |
39 |
Correct |
1 ms |
6488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6584 KB |
Output is correct |
3 |
Correct |
2 ms |
6488 KB |
Output is correct |
4 |
Correct |
2 ms |
6488 KB |
Output is correct |
5 |
Correct |
2 ms |
6488 KB |
Output is correct |
6 |
Correct |
2 ms |
6488 KB |
Output is correct |
7 |
Correct |
2 ms |
6488 KB |
Output is correct |
8 |
Correct |
3 ms |
6488 KB |
Output is correct |
9 |
Correct |
2 ms |
6488 KB |
Output is correct |
10 |
Correct |
3 ms |
6488 KB |
Output is correct |
11 |
Correct |
14 ms |
6488 KB |
Output is correct |
12 |
Correct |
13 ms |
6488 KB |
Output is correct |
13 |
Correct |
10 ms |
6488 KB |
Output is correct |
14 |
Correct |
4 ms |
6488 KB |
Output is correct |
15 |
Correct |
5 ms |
6488 KB |
Output is correct |
16 |
Correct |
3 ms |
6488 KB |
Output is correct |
17 |
Correct |
4 ms |
6488 KB |
Output is correct |
18 |
Correct |
1 ms |
6488 KB |
Output is correct |
19 |
Correct |
1 ms |
6488 KB |
Output is correct |
20 |
Correct |
3 ms |
6484 KB |
Output is correct |
21 |
Correct |
11 ms |
6488 KB |
Output is correct |
22 |
Correct |
4 ms |
6488 KB |
Output is correct |
23 |
Correct |
5 ms |
6488 KB |
Output is correct |
24 |
Correct |
3 ms |
6488 KB |
Output is correct |
25 |
Correct |
1 ms |
6488 KB |
Output is correct |
26 |
Correct |
1 ms |
6488 KB |
Output is correct |
27 |
Correct |
2 ms |
6488 KB |
Output is correct |
28 |
Correct |
3 ms |
6488 KB |
Output is correct |
29 |
Correct |
3 ms |
6488 KB |
Output is correct |
30 |
Correct |
2 ms |
6488 KB |
Output is correct |
31 |
Correct |
2 ms |
6488 KB |
Output is correct |
32 |
Correct |
3 ms |
6488 KB |
Output is correct |
33 |
Correct |
1 ms |
6488 KB |
Output is correct |
34 |
Correct |
1 ms |
6488 KB |
Output is correct |
35 |
Correct |
1 ms |
6488 KB |
Output is correct |
36 |
Correct |
2 ms |
6488 KB |
Output is correct |
37 |
Correct |
2 ms |
6488 KB |
Output is correct |
38 |
Correct |
1 ms |
6488 KB |
Output is correct |
39 |
Correct |
1 ms |
6488 KB |
Output is correct |
40 |
Correct |
1 ms |
6488 KB |
Output is correct |
41 |
Correct |
2 ms |
6488 KB |
Output is correct |
42 |
Correct |
1 ms |
6488 KB |
Output is correct |
43 |
Correct |
1 ms |
6488 KB |
Output is correct |
44 |
Correct |
2 ms |
6488 KB |
Output is correct |
45 |
Correct |
3 ms |
6488 KB |
Output is correct |
46 |
Correct |
2 ms |
6488 KB |
Output is correct |
47 |
Correct |
2 ms |
6488 KB |
Output is correct |
48 |
Correct |
2 ms |
6488 KB |
Output is correct |
49 |
Correct |
3 ms |
6488 KB |
Output is correct |
50 |
Correct |
14 ms |
6488 KB |
Output is correct |
51 |
Correct |
13 ms |
6556 KB |
Output is correct |
52 |
Correct |
10 ms |
6488 KB |
Output is correct |
53 |
Correct |
3 ms |
6488 KB |
Output is correct |
54 |
Correct |
5 ms |
6488 KB |
Output is correct |
55 |
Correct |
2 ms |
6488 KB |
Output is correct |
56 |
Correct |
3 ms |
6488 KB |
Output is correct |
57 |
Correct |
1 ms |
6488 KB |
Output is correct |
58 |
Correct |
36 ms |
6488 KB |
Output is correct |
59 |
Correct |
53 ms |
6484 KB |
Output is correct |
60 |
Correct |
8 ms |
6488 KB |
Output is correct |
61 |
Correct |
57 ms |
6488 KB |
Output is correct |
62 |
Correct |
9 ms |
6488 KB |
Output is correct |
63 |
Correct |
53 ms |
6488 KB |
Output is correct |
64 |
Execution timed out |
4013 ms |
6488 KB |
Time limit exceeded |
65 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6488 KB |
Output is correct |
3 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
1 ms |
6488 KB |
Output is correct |
5 |
Correct |
33 ms |
13540 KB |
Output is correct |
6 |
Correct |
45 ms |
15284 KB |
Output is correct |
7 |
Correct |
23 ms |
10960 KB |
Output is correct |
8 |
Correct |
52 ms |
15292 KB |
Output is correct |
9 |
Correct |
9 ms |
8024 KB |
Output is correct |
10 |
Correct |
41 ms |
15168 KB |
Output is correct |
11 |
Execution timed out |
4014 ms |
13260 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6488 KB |
Output is correct |
3 |
Correct |
2 ms |
6488 KB |
Output is correct |
4 |
Correct |
894 ms |
10704 KB |
Output is correct |
5 |
Execution timed out |
4058 ms |
15288 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6488 KB |
Output is correct |
3 |
Correct |
2 ms |
6488 KB |
Output is correct |
4 |
Correct |
894 ms |
10704 KB |
Output is correct |
5 |
Execution timed out |
4058 ms |
15288 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
2 ms |
6488 KB |
Output is correct |
3 |
Execution timed out |
4057 ms |
12772 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |