Submission #859614

# Submission time Handle Problem Language Result Execution time Memory
859614 2023-10-10T11:25:32 Z Tudy006 Peru (RMI20_peru) C++14
0 / 100
2 ms 2396 KB
#include <bits/stdc++.h>

using namespace std;

const int NMAX = 2500000;
const int MOD = 1e9 + 7;

long long dp[NMAX];

int solve( int n, int k, int* v ) {
    deque <int> dq;

//    cout << n << ' ' << k << endl;
    for ( int i = 0; i < n; i ++ ) {
        while ( !dq.empty() && v[dq.back()] <= v[i] ) dq.pop_back();
        dq.push_back( i );
        dp[i] = v[dq.front()] + ( i >= k ? dp[i - k] : 0 );
        for ( int j = 1; j < dq.size(); j ++ ) {
            dp[i] = min( dp[i], dp[dq[j - 1]] + v[dq[j]] );
        }
    }
    int ans = 0;
    for ( int i = 0; i < n; i ++ ) {
        ans = ( (long long)ans * 23 + dp[i] ) % MOD;
    }
    return ans;
}

Compilation message

peru.cpp: In function 'int solve(int, int, int*)':
peru.cpp:18:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         for ( int j = 1; j < dq.size(); j ++ ) {
      |                          ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -