Submission #355409

# Submission time Handle Problem Language Result Execution time Memory
355409 2021-01-22T12:55:36 Z juggernaut Ancient Books (IOI17_books) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include"books.h"
using namespace std;
long long minimum_walk(vector<int> a,int s){
	int n=a.size();
	while(a[n-1]==n-1)n--;
	long long ans=0;
	for(int i=0;i<n;i++)ans+=abs(i-a[i]);
	int pivot=0;
	for(int i=0;i<n-1;i++){
		pivot=max(pivot,a[i]);
		if(i==pivot)ans+=2;
	}
	return ans;

Compilation message

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:14:12: error: expected '}' at end of input
   14 |  return ans;
      |            ^
books.cpp:4:44: note: to match this '{'
    4 | long long minimum_walk(vector<int> a,int s){
      |                                            ^