Submission #478278

# Submission time Handle Problem Language Result Execution time Memory
478278 2021-10-06T19:17:40 Z stefantaga Peru (RMI20_peru) C++14
0 / 100
1 ms 340 KB
#include<bits/stdc++.h>
#define MOD 1000000007
#include "peru.h"
using namespace std;
int din[2500005];
int min1(int a,int b)
{
    if (a<b)
        {
            return a;
        }
    return b;
}
int max1(int a,int b)
{
    if (a>b)
    {
        return a;
    }
    return b;
}
int solve(int n, int k, int* v){
    int put=1,maxim,i,j,suma=0;
    for (i=0;i<n;i++)
    {
        maxim=0;
        din[i]=1000000007;
        int lim=max1(i-k+1,0);
        for (j=i;j>=lim;j--)
        {
            maxim=max1(maxim,v[j]);
            if (j==0)
            {
                din[i]=min1(din[i],maxim);
                continue;
            }
            din[i]=min1(din[i],din[j-1]+maxim);
        }
    }
    for (i=n-1;i>=0;i--)
    {
        suma=(suma+(1LL*put*din[i])%MOD)%MOD;
        put=(1LL*23*put)%MOD;
    }
    return suma;
}
/*
static int s[2500005];
static int n, k;
int main(){
    cin>> n >> k;
    for(int i = 0; i < n; i++){
        cin>> s[i];
    }
    int ans = solve(n, k, s);
    cout<< ans <<"\n";
    return 0;
}
*/
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -