답안 #494517

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494517 2021-12-15T16:46:50 Z leaked Peru (RMI20_peru) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define f first
#define s second
#define m_p make_pair
#define vec vector
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fast_rmi ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;
typedef long long ll;
const int N=4e5+1;
const int M=1e9+7;
ll dp[N];
ll pw[N];

int solve(int n,int k,int *a){
    int ans=0;
    pw[0]=1;
    for(int i=1;i<n;i++)
        pw[i]=1ll*pw[i-1]*23%M;
    for(int i=1;i<=n;i++){
        dp[i]=1e18;
        int mx=-1;
        for(int j=i-1;j>=0 && j>=i-k;j--){
            mx=max(mx,a[j]);
            dp[i]=min(dp[i],dp[j]+mx);
        }
//        cout<<dp[i]<<' ';
//        ans*=23;ans%=M;
//        ans+=(dp[i]%M);ans%=M;
        ans+=1ll*(dp[i]%M)*pw[n-i];
        ans%=M;
    }
    return ans;
}
int a[100];
signed main(){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    cout<<solve(n,k,a);
}

Compilation message

/usr/bin/ld: /tmp/cczA1kJ3.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc6K4Q84.o:peru.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status