Submission #1092640

# Submission time Handle Problem Language Result Execution time Memory
1092640 2024-09-24T16:25:08 Z alexdd Peru (RMI20_peru) C++17
0 / 100
3 ms 344 KB
#include "peru.h"
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const int INF = 1e18;
int a[2500005];
long long dp[2500005];
int solve(int n, int k, int* v)
{
    for(int i=1;i<=n;i++)
    {
        a[i]=v[i-1];
        dp[i]=INF;
        int mxm=0;
        for(int j=i-1;j>=0;j--)
        {
            mxm = max(mxm, a[j+1]);
            if(j==i-k || a[j+1]==mxm)
            {
                dp[i] = min(dp[i], dp[j]+mxm);
            }
        }
    }

    long long rez=0,put23=1;
    for(int i=n;i>0;i--)
    {
        rez = (rez + put23*dp[i])%MOD;
        put23 = put23*23LL%MOD;
    }
    return rez;
}
/*
8 3
3 2 9 8 7 11 3 4

*/

Compilation message

peru.cpp:5:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    5 | const int INF = 1e18;
      |                 ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -