#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;
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;
for(ll i=A;i<=B;++i)
{
q.push({i,0});
memset(vis,false,sizeof vis);
while(q.size())
{
p=q.front();
q.pop();
if(vis[p.first])continue;
vis[p.first]=1;
if(C<=p.first && p.first<=D)
x=(x==-1?p.second:min(x,p.second));
++p.second;
for(auto j:v[p.first])q.push({j,p.second});
}
}
return x;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6488 KB |
Output is correct |
3 |
Execution timed out |
4029 ms |
11420 KB |
Time limit exceeded |
4 |
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 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
1 ms |
6488 KB |
Output is correct |
5 |
Correct |
4 ms |
6488 KB |
Output is correct |
6 |
Correct |
29 ms |
6484 KB |
Output is correct |
7 |
Correct |
17 ms |
6488 KB |
Output is correct |
8 |
Correct |
26 ms |
6488 KB |
Output is correct |
9 |
Correct |
6 ms |
6488 KB |
Output is correct |
10 |
Correct |
23 ms |
6488 KB |
Output is correct |
11 |
Correct |
37 ms |
6488 KB |
Output is correct |
12 |
Correct |
36 ms |
6488 KB |
Output is correct |
13 |
Correct |
40 ms |
6488 KB |
Output is correct |
14 |
Correct |
26 ms |
6484 KB |
Output is correct |
15 |
Correct |
49 ms |
6488 KB |
Output is correct |
16 |
Correct |
16 ms |
6488 KB |
Output is correct |
17 |
Correct |
38 ms |
6724 KB |
Output is correct |
18 |
Correct |
1 ms |
6488 KB |
Output is correct |
19 |
Correct |
2 ms |
6488 KB |
Output is correct |
20 |
Correct |
23 ms |
6488 KB |
Output is correct |
21 |
Correct |
41 ms |
6488 KB |
Output is correct |
22 |
Correct |
24 ms |
6488 KB |
Output is correct |
23 |
Correct |
53 ms |
6488 KB |
Output is correct |
24 |
Correct |
37 ms |
6484 KB |
Output is correct |
25 |
Correct |
2 ms |
6488 KB |
Output is correct |
26 |
Correct |
1 ms |
6572 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 |
3 ms |
6488 KB |
Output is correct |
31 |
Correct |
3 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 |
2 ms |
6488 KB |
Output is correct |
36 |
Correct |
3 ms |
6488 KB |
Output is correct |
37 |
Correct |
2 ms |
6488 KB |
Output is correct |
38 |
Correct |
2 ms |
6488 KB |
Output is correct |
39 |
Correct |
3 ms |
6488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
2 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 |
4 ms |
6488 KB |
Output is correct |
6 |
Correct |
29 ms |
6484 KB |
Output is correct |
7 |
Correct |
17 ms |
6488 KB |
Output is correct |
8 |
Correct |
26 ms |
6488 KB |
Output is correct |
9 |
Correct |
6 ms |
6488 KB |
Output is correct |
10 |
Correct |
23 ms |
6488 KB |
Output is correct |
11 |
Correct |
37 ms |
6488 KB |
Output is correct |
12 |
Correct |
36 ms |
6488 KB |
Output is correct |
13 |
Correct |
40 ms |
6488 KB |
Output is correct |
14 |
Correct |
26 ms |
6484 KB |
Output is correct |
15 |
Correct |
49 ms |
6488 KB |
Output is correct |
16 |
Correct |
16 ms |
6488 KB |
Output is correct |
17 |
Correct |
38 ms |
6724 KB |
Output is correct |
18 |
Correct |
1 ms |
6488 KB |
Output is correct |
19 |
Correct |
2 ms |
6488 KB |
Output is correct |
20 |
Correct |
23 ms |
6488 KB |
Output is correct |
21 |
Correct |
41 ms |
6488 KB |
Output is correct |
22 |
Correct |
24 ms |
6488 KB |
Output is correct |
23 |
Correct |
53 ms |
6488 KB |
Output is correct |
24 |
Correct |
37 ms |
6484 KB |
Output is correct |
25 |
Correct |
2 ms |
6488 KB |
Output is correct |
26 |
Correct |
1 ms |
6572 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 |
3 ms |
6488 KB |
Output is correct |
31 |
Correct |
3 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 |
2 ms |
6488 KB |
Output is correct |
36 |
Correct |
3 ms |
6488 KB |
Output is correct |
37 |
Correct |
2 ms |
6488 KB |
Output is correct |
38 |
Correct |
2 ms |
6488 KB |
Output is correct |
39 |
Correct |
3 ms |
6488 KB |
Output is correct |
40 |
Correct |
1 ms |
6488 KB |
Output is correct |
41 |
Correct |
1 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 |
4 ms |
6488 KB |
Output is correct |
45 |
Correct |
26 ms |
6488 KB |
Output is correct |
46 |
Correct |
18 ms |
6488 KB |
Output is correct |
47 |
Correct |
25 ms |
6488 KB |
Output is correct |
48 |
Correct |
6 ms |
6488 KB |
Output is correct |
49 |
Correct |
23 ms |
6584 KB |
Output is correct |
50 |
Correct |
36 ms |
6484 KB |
Output is correct |
51 |
Correct |
36 ms |
6488 KB |
Output is correct |
52 |
Correct |
35 ms |
6488 KB |
Output is correct |
53 |
Correct |
26 ms |
6488 KB |
Output is correct |
54 |
Correct |
53 ms |
6488 KB |
Output is correct |
55 |
Correct |
15 ms |
6488 KB |
Output is correct |
56 |
Correct |
37 ms |
6488 KB |
Output is correct |
57 |
Correct |
1 ms |
6488 KB |
Output is correct |
58 |
Correct |
1532 ms |
6744 KB |
Output is correct |
59 |
Correct |
2375 ms |
6744 KB |
Output is correct |
60 |
Correct |
250 ms |
6744 KB |
Output is correct |
61 |
Correct |
2398 ms |
6744 KB |
Output is correct |
62 |
Correct |
171 ms |
6488 KB |
Output is correct |
63 |
Correct |
2426 ms |
6744 KB |
Output is correct |
64 |
Execution timed out |
4091 ms |
6744 KB |
Time limit exceeded |
65 |
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 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
2 ms |
6488 KB |
Output is correct |
5 |
Correct |
231 ms |
12844 KB |
Output is correct |
6 |
Correct |
510 ms |
14416 KB |
Output is correct |
7 |
Correct |
19 ms |
10588 KB |
Output is correct |
8 |
Correct |
614 ms |
14556 KB |
Output is correct |
9 |
Correct |
84 ms |
7996 KB |
Output is correct |
10 |
Correct |
242 ms |
14416 KB |
Output is correct |
11 |
Execution timed out |
4037 ms |
12568 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
2 ms |
6484 KB |
Output is correct |
3 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
245 ms |
10288 KB |
Output is correct |
5 |
Correct |
1010 ms |
14536 KB |
Output is correct |
6 |
Correct |
641 ms |
8272 KB |
Output is correct |
7 |
Correct |
972 ms |
14536 KB |
Output is correct |
8 |
Correct |
567 ms |
9304 KB |
Output is correct |
9 |
Correct |
1014 ms |
14548 KB |
Output is correct |
10 |
Execution timed out |
4040 ms |
11836 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
2 ms |
6484 KB |
Output is correct |
3 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
245 ms |
10288 KB |
Output is correct |
5 |
Correct |
1010 ms |
14536 KB |
Output is correct |
6 |
Correct |
641 ms |
8272 KB |
Output is correct |
7 |
Correct |
972 ms |
14536 KB |
Output is correct |
8 |
Correct |
567 ms |
9304 KB |
Output is correct |
9 |
Correct |
1014 ms |
14548 KB |
Output is correct |
10 |
Execution timed out |
4040 ms |
11836 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6488 KB |
Output is correct |
3 |
Execution timed out |
4029 ms |
11420 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |