Submission #901389

#TimeUsernameProblemLanguageResultExecution timeMemory
901389nxteruAncient Books (IOI17_books)C++14
Compilation error
0 ms0 KiB
using ll =long long;
int minimum_walk(int[] p, int s){
	int n=sizeof(p);
	ll ans=0;
	int ma=0;
	for(int i=0;i<n;i++){
		ans+=abs(p[i]-i);
		ma=max(ma,p[i]);
		if(ma<=i&&i<n-1)ans+=2;
	}
	return ans;
}

Compilation message (stderr)

books.cpp:2:24: error: expected ',' or '...' before 'p'
    2 | int minimum_walk(int[] p, int s){
      |                        ^
books.cpp: In function 'int minimum_walk(int*)':
books.cpp:3:15: error: 'p' was not declared in this scope
    3 |  int n=sizeof(p);
      |               ^
books.cpp:7:8: error: 'abs' was not declared in this scope; did you mean 'ans'?
    7 |   ans+=abs(p[i]-i);
      |        ^~~
      |        ans
books.cpp:8:6: error: 'max' was not declared in this scope; did you mean 'ma'?
    8 |   ma=max(ma,p[i]);
      |      ^~~
      |      ma