이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "books.h"
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
int n;
int startTo[1000000];
int searchR(int pos){
for(int i = pos ; i < n ; i ++){
if(startTo[i] != -1)return i;
}
return -1;
}
int searchL(int pos){
for(int i = 0 ; i < n; i ++){
if(startTo[i] != -1)return i;
}
return -1;
}
int pos = 0, temp;
ll ans = 0;
void ir(int siguiente){
ans += abs(siguiente-pos);
pos = siguiente;
}
long long minimum_walk(std::vector<int> p, int s) {
n = p.size();
int cont = 0;
for(int i = 0 ; i < n ; i ++){
startTo[i] = -1;
if(p[i] > i){
startTo[i] = p[i];
cont ++;
}
}
while(true){
int nextL = searchL(pos);
if(nextL != -1){
ir(nextL);
temp = pos;
ir(startTo[pos]);
startTo[temp] = -1;
continue;
}
ans+= pos;
return ans;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |