답안 #901389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
901389 2024-01-09T11:31:04 Z nxteru 고대 책들 (IOI17_books) C++14
컴파일 오류
0 ms 0 KB
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

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