제출 #488603

#제출 시각아이디문제언어결과실행 시간메모리
488603alexander707070Peru (RMI20_peru)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define MAXN 400007 #define INF 1e16 using namespace std; int n,k; long long s[MAXN],res; const long long mod=1000000007; bool li[MAXN]; long long dp[MAXN]; bool u[MAXN][20]; long long ans[MAXN][20]; int power[20],lg[MAXN]; void calc(){ power[0]=1; for(int i=1;i<20;i++)power[i]=power[i-1]*2; lg[1]=0; for(int i=2;i<MAXN;i++)lg[i]=lg[i/2]+1; } long long rmq(int i,int j){ if(j==0)return s[i]; if(u[i][j])return ans[i][j]; u[i][j]=true; ans[i][j]=max(rmq(i,j-1),rmq(i+power[j-1],j-1)); return ans[i][j]; } long long getmax(int l,int r){ return max( rmq(l,lg[r-l+1]) , rmq(r-power[lg[r-l+1]]+1,lg[r-l+1]) ); } long long ff(int n){ if(n==0)return 0; if(li[n])return dp[n]; li[n]=true; dp[n]=INF; for(int i=n;i>=max(1,n-k+1);i--){ dp[n]=min(dp[n],getmax(i,n)+ff(i-1)); } return dp[n]; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>k; for(int i=1;i<=n;i++){ cin>>s[i]; } calc(); for(int i=1;i<=n;i++){ res*=23;res+=ff(i); res%=mod; } cout<<res<<"\n"; return 0; }

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

/usr/bin/ld: /tmp/cc9cGFrG.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc1nn7tG.o:peru.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc9cGFrG.o: in function `main':
grader.cpp:(.text.startup+0x144): undefined reference to `solve(int, int, int*)'
collect2: error: ld returned 1 exit status