Submission #1061312

#TimeUsernameProblemLanguageResultExecution timeMemory
1061312fv3Ancient Books (IOI17_books)C++14
0 / 100
1 ms348 KiB
#include "books.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll minimum_walk(vector<int> P, int S) 
{
	const int N = P.size();	

	ll res = 0;
	for (int i = 0; i < N; i++)
	{
		res += abs(P[i] - i);
	}
	int sort_length = 0;
	while (sort_length < N && P[sort_length] == sort_length)
		sort_length++;

	if (sort_length < N)
		res += sort_length;

	return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...