답안 #900528

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
900528 2024-01-08T12:45:06 Z Cookie Peru (RMI20_peru) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define sz(a) (int)a.size()
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mpp make_pair
#include<iostream>
//#include "peru.h"
using namespace std;
const int mxn = 4e5 + 5;
const ll mod = 1e9 + 7;
ll a[mxn + 1];
ll dp[mxn + 1], pw[mxn + 1];
int solve(int n, int k, int* v){
    pw[0] = 1;
    for(int i = 1; i < n; i++)pw[i] = (pw[i - 1] * 23) % mod;
    for(int i = 1; i <= n; i++)a[i] = v[i - 1];
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        dp[i] = dp[i - 1] + a[i];
        ll mx = a[i];
        for(int j = i - 1; j >= max(i - k + 1, 1); j--){
            mx = max(mx, a[j]);
            dp[i] = min(dp[i], dp[j - 1] + mx);
        }
        ans = (ans + (dp[i] % mod) * pw[n - i]) % mod;
        //cout << dp[i] << " ";
    }
    cout << ans;
    return 0;
}

static int s[2500005];
static int n, k;
int main(){
    cin>> n >> k;
    for(int i = 0; i < n; i++){
        cin>> s[i];
    }
    int ans = solve(n, k, s);
    cout<< ans <<"\n";
    return 0;
}

Compilation message

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