// Esti <3
//\
šťastia pre nás :)
// you're already the best
// _
// ^ ^ //
// >(O_O)<___//
// \ __ __ \
// \\ \\ \\\\
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("O3","unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3")
#pragma GCC target("popcnt")
using ll = long long;
#define int long long
#define forn(i,n) for(int i=0; i<(n); ++i)
#define pb push_back
#define pi pair<int,int>
#define f first
#define s second
#define vii(a,n) vector<int> a(n); forn(i,n) cin>>a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll inf = 1e18;
const ll mod = 1e9+7;//998244853;
// \
\
:smiling_face_with_3_hearts: :smiling_face_with_3_hearts: :smiling_face_with_3_hearts:
//vidime sa veľmi skoro, moje slnko
int32_t solve(int32_t n, int32_t k, int32_t* a){
vector<int> dp(n+1,inf);
dp[0]=0;
for (int i=1; i<=n; ++i) {
int m=0;
for(int j=i-1; j>=0 && i-j<=k; --j) {
m=max(m,1ll*a[j]);
dp[i]=min(dp[i],dp[j]+m);
}
}
int ans=0, p=1;
for (int i=n; i; --i) {
dp[i]%=mod;
ans=(ans+p*dp[i])%mod;
p=(p*23)%mod;
}
return ans;
}
Compilation message
peru.cpp:3:1: warning: multi-line comment [-Wcomment]
3 | //\
| ^
peru.cpp:9:1: warning: multi-line comment [-Wcomment]
9 | // \ __ __ \
| ^
peru.cpp:36:1: warning: multi-line comment [-Wcomment]
36 | // \
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
463 ms |
5724 KB |
Output is correct |
16 |
Correct |
376 ms |
5724 KB |
Output is correct |
17 |
Correct |
216 ms |
5724 KB |
Output is correct |
18 |
Correct |
258 ms |
5724 KB |
Output is correct |
19 |
Correct |
361 ms |
5724 KB |
Output is correct |
20 |
Execution timed out |
651 ms |
5720 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
463 ms |
5724 KB |
Output is correct |
2 |
Correct |
376 ms |
5724 KB |
Output is correct |
3 |
Correct |
216 ms |
5724 KB |
Output is correct |
4 |
Correct |
258 ms |
5724 KB |
Output is correct |
5 |
Correct |
361 ms |
5724 KB |
Output is correct |
6 |
Execution timed out |
651 ms |
5720 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |