Submission #533932

#TimeUsernameProblemLanguageResultExecution timeMemory
533932amunduzbaevPeru (RMI20_peru)C++17
18 / 100
581 ms3540 KiB
#include "bits/stdc++.h" using namespace std; #include "peru.h" #ifndef EVAL #include "grader.cpp" #endif #define i32 int32_t #define ar array #define int long long const int N = 2e3 + 5; const int mod = 1e9 + 7; int a[N], dp[N]; i32 solve(i32 n, i32 k, i32* a){ memset(dp, 127, sizeof dp); for(int i=0;i<n;i++){ int mx = a[i]; for(int j=i-1;j>=max(0ll, i-k);j--){ dp[i] = min(dp[i], dp[j] + mx); mx = max(mx, 1ll * a[j]); } if(i < k) dp[i] = min(dp[i], mx); } int res = 0; for(int i=0;i<n;i++){ res = (res * 23ll + dp[i]) % mod; //~ cout<<dp[i]<<" "; } //~ cout<<"\n"; return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...