제출 #901389

#제출 시각아이디문제언어결과실행 시간메모리
901389nxteruAncient Books (IOI17_books)C++14
컴파일 에러
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; }

컴파일 시 표준 에러 (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