답안 #399331

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
399331 2021-05-05T15:10:49 Z rocks03 Peru (RMI20_peru) C++14
18 / 100
600 ms 8844 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int M = 1e9 + 7;

int solve(int N, int K, int* a){
    vector<ll> dp(N + 1, LLONG_MAX);
    dp[0] = 0;
    rep(i, 1, N + 1){
        int mx = 0;
        per(j, i, max(1, i - K + 1)){
            mx = max(mx, a[j - 1]);
            dp[i] = min(dp[i], dp[j - 1] + mx);
        }
    }
    vector<ll> pt(N + 1);
    pt[N] = 1;
    per(i, N - 1, 1){
        pt[i] = (pt[i + 1] * 23ll) % M;
    }
    ll ans = 0;
    rep(i, 1, N + 1){
        dp[i] %= M; pt[i] %= M;
        ans += (dp[i] * pt[i]) % M;
        ans %= M;
    }
    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 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 352 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 1 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 352 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 618 ms 8844 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 618 ms 8844 KB Time limit exceeded
2 Halted 0 ms 0 KB -