Submission #858859

#TimeUsernameProblemLanguageResultExecution timeMemory
858859alexdumitruPeru (RMI20_peru)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int solve(int n, int k, int *s) { int deq[n], dp[n]; int l = 0, r = -1, mul = 1, ans = 0; for(int i = 0; i < n; i++) { while(r >= l && s[deq[r]] <= s[i]) r--; deq[++r] = i; if(deq[l] <= i - k) l++; int nextDp = i >= k ? dp[i - k] : 0; dp[i] = (nextDp + s[deq[l]]) % MOD; } for(int i = n - 1; i >= 0; i--) { ans = (1LL * ans + 1LL * dp[i] * mul % MOD) % MOD; mul = (1LL * mul * 23) % MOD; } return ans; } int main() { int n, k; cin >> n >> k; int *a = new int[n]; for(int i = 0; i < n; i++) cin >> a[i]; cout << solve(n, k, a) << '\n'; return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccgWWzg9.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccoAVzv6.o:peru.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status