제출 #128257

#제출 시각아이디문제언어결과실행 시간메모리
128257thanosHomecoming (BOI18_homecoming)C++14
컴파일 에러
0 ms0 KiB
#include<homecoming.h> using namespace std; long long int C(int i,int j,int u,int *B){ int sum=0; for(int k=j; k<=j+u-1; k++){ if(j==0) break; if(k>=i){ sum-=B[k-1]; } } for(int k=i; k<=i+u-1; k++){ sum+=B[k-1]; } return sum; } long long int solve(int N,int K,int *A,int *B){ int BB[10005]; for(int i=0; i<N; i++){ BB[i]=BB[i+N]=B[i]; } long long int dp[10005]={0}; long long int mx=0; for(int i=1; i<=N; i++){ dp[i]=dp[i-1]+A[i-1]-C(i,i-1,K,BB); for(int j=i-2; j>=0; j--){ dp[i]=max(dp[i],dp[j]+A[i-1]-C(i,j,K,BB)); mx=max(mx,dp[i]); } } return mx; }

컴파일 시 표준 에러 (stderr) 메시지

homecoming.cpp: In function 'long long int solve(int, int, int*, int*)':
homecoming.cpp:26:13: error: 'max' was not declared in this scope
       dp[i]=max(dp[i],dp[j]+A[i-1]-C(i,j,K,BB));
             ^~~
homecoming.cpp:26:13: note: suggested alternative: 'mx'
       dp[i]=max(dp[i],dp[j]+A[i-1]-C(i,j,K,BB));
             ^~~
             mx