Submission #1224277

#TimeUsernameProblemLanguageResultExecution timeMemory
1224277Sir_Ahmed_ImranPeru (RMI20_peru)C++17
18 / 100
1094 ms24600 KiB
#include "peru.h" #include <bits/stdc++.h> using namespace std; #define N 2500001 #define nl '\n' #define ff first #define ss second #define add insert #define ll long long #define ld long double #define terminator main #define pll pair<ll,ll> #define append push_back #define pii pair<int,int> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ll x[N]; int a[N]; int mod = 1e9 + 7; int add(int x, int y){ return (x + y) % mod; } int mul(int x, int y){ return (1ll * x * y) % mod; } int solve(int n, int k, int* v){ int mx, ans, c; for(int i = 0; i < n; i++) a[i + 1] = v[i]; for(int i = 1; i <= n; i++){ x[i] = x[i - 1] + a[i]; mx = a[i]; for(int j = i - 1; j > max(i - k, 0); j--){ mx = max(mx, a[j]); x[i] = min(x[i], x[j - 1] + mx); } } c = 1; ans = 0; for(int i = n; i > 0; i--){ x[i] %= mod; ans = add(ans, mul(x[i], c)); c = mul(c, 23); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...