답안 #640073

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
640073 2022-09-13T13:47:08 Z danikoynov Peru (RMI20_peru) C++14
18 / 100
600 ms 11112 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 2010;
const ll inf = 1e18, mod = 1e9 + 7;

ll a[maxn], dp[maxn];
int solve(int n, int k, int *S)
{
    for (int i = 0; i < n; i ++)
        a[i + 1] = S[i];

    for (int i = 1; i <= n; i ++)
    {
        dp[i] = inf;
        ll mx = a[i];
        for (int j = i - 1; j >= max(0, i - k); j --)
        {
            dp[i] = min(dp[i], dp[j] + mx);
            mx = max(mx, a[j]);
        }
    }

    /**for (int i = 1; i <= n; i ++)
        cout << dp[i] << " ";
    cout << endl;*/
    ll cur = 1, ans = 0;
    for (int i = n; i > 0; i --)
    {
        ans = (ans + (dp[i] % mod) * cur) % mod;
        cur = (cur * (ll)23) % mod;
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 336 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 328 KB Output is correct
14 Correct 0 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 1 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 336 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 328 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Execution timed out 632 ms 11112 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 632 ms 11112 KB Time limit exceeded
2 Halted 0 ms 0 KB -