답안 #493490

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493490 2021-12-11T16:15:09 Z Jeff12345121 Peru (RMI20_peru) C++17
18 / 100
600 ms 3540 KB
#include <bits/stdc++.h>
#define int long long
#define ll int
#include "peru.h"
using namespace std;

const ll nmax = 2005;
const ll P = 1000000007;


ll dp[nmax];
int32_t solve(int32_t N, int32_t K, int32_t* S) {
    for (ll i = 1; i <= N; i++) dp[i] = LLONG_MAX;
    for (ll i = 1; i <= N; i++) {
        ll maxSoFar = -1;
        for (ll j = i - 1; j >= 0 && j >= i - K; j--) {
            maxSoFar = max(maxSoFar, 1LL * S[j]);
            dp[i] = min(dp[i], (dp[j] + maxSoFar));
        }
    }

    int dhs=1, ans=0;
    for(int i=N; i>=1; i--)
    {
        ans+=(dp[i]%P*dhs)%P;
        ans%=P;
        dhs=(dhs*23)%P;
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Execution timed out 1086 ms 3540 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1086 ms 3540 KB Time limit exceeded
2 Halted 0 ms 0 KB -