#include "books.h"
#include <bits/stdc++.h>
using namespace std;
long long minimum_walk(vector<int>P,int S){
assert(S==0);
int N=P.size();
int d=0;
int p=0;
int h=P[0];
P[0]=-1;
while(true){
bool f=false;
for(int i=p;i<N;i++){
if(P[i]<h)f=true;
}
if(f){
int l;
for(int i=p;i<N;i++){
if(P[i]<h){
swap(P[i],h);
l=i;
}
}
d+=l-p;
l=p;
continue;
}
for(int i=p;i>=0;i--){
if(P[i]>h)f=true;
}
if(f){
int l;
for(int i=p;i>=0;i--){
if(P[i]>h){
swap(P[i],h);
l=i;
}
}
d+=p-l;
l=p;
continue;
}
d+=p;
break;
}
return d;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2043 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2043 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2043 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2043 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |