#include "books.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long minimum_walk(vector<int> p, int s) {
int c = 0, n = p.size();
for(; n && p[n - 1] == n - 1; -- n);
for(int cr = 0, take = -1; n;) {
if(cr == p[cr]) {
cr += (take == -1 || take > cr ? +1 : -1);
continue;
}
if(take == cr) {
swap(take, p[cr]);
if(cr == n - 1) {
-- n;
}
} else if(take == -1) {
take = p[cr];
p[cr] = 0;
} else if(take < p[cr]){
swap(take, p[cr]);
}
}
return c;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2059 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2059 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2059 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2047 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2059 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |