답안 #596683

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
596683 2022-07-15T01:16:52 Z definitelynotmee Peru (RMI20_peru) C++17
0 / 100
1 ms 340 KB
#include "peru.h"
#include<bits/stdc++.h>
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T>
using matrix = vector<vector<T>>;
const ll INFL = 1ll<<60;
const int MOD = 1e9+7;

int solve(int n, int k, int* V){
    
    vector<int> v(V,V+n);
    v.insert(v.begin(),0);

    vector<ll> dp(n+1,INFL);
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        int maxrange = 0;
        for(int j = i-1; j >= max(i-k,0); j--){
            maxrange = max(maxrange,v[j+1]);
            dp[i] = min(dp[i],maxrange+dp[j]);
        }
    }

    ll resp = 0;
    ll power = 1;
    for(int i = n; i > 0; i--){
        resp+=power*dp[i];
        power*=23;
        power%=MOD;
        resp%=MOD;
    }
    
    return resp;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -