# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
596431 |
2022-07-14T18:18:08 Z |
CaroLinda |
Peru (RMI20_peru) |
C++14 |
|
538 ms |
34808 KB |
#include "peru.h"
#include <bits/stdc++.h>
#define ll long long
const int MAXN = 2500005;
const ll PRIME = 23;
const ll MOD = 1e9+7;
using namespace std;
ll dp[MAXN];
multiset<ll> ans;
deque<int> dq;
int solve(int n, int k, int* v){
for(int i = 0; i < n; i++){
while(!dq.empty() && dq.front() < i-k){
int id = dq.front();
dq.pop_front();
if(!dq.empty())
ans.erase(ans.find(dp[id]+v[dq.front()]));
}
while(!dq.empty() && v[dq.back()] <= v[i]){
ll tot = v[dq.back()];
dq.pop_back();
if(!dq.empty()){
ans.erase(ans.find(dp[dq.back()]+tot));
}
}
if(!dq.empty()){
ans.insert(dp[dq.back()]+v[i]);
}
dq.push_back(i);
ll aux = i-k < 0 ? 0 : dp[i-k];
dp[i] = aux+v[dq.front()];
if(!ans.empty()) dp[i] = min(dp[i], *ans.begin());
}
/*for(int i = 0; i < n; i++)
cout << dp[i] << " ";
cout << endl;*/
ll tot = 0;
for(int i = 0; i < n; i++){
tot *= PRIME;
tot %= MOD;
tot += dp[i];
tot %= MOD;
}
return tot;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
64 ms |
5072 KB |
Output is correct |
16 |
Correct |
69 ms |
5060 KB |
Output is correct |
17 |
Correct |
59 ms |
5028 KB |
Output is correct |
18 |
Correct |
41 ms |
5016 KB |
Output is correct |
19 |
Correct |
41 ms |
5064 KB |
Output is correct |
20 |
Correct |
52 ms |
5048 KB |
Output is correct |
21 |
Correct |
61 ms |
5164 KB |
Output is correct |
22 |
Correct |
64 ms |
5188 KB |
Output is correct |
23 |
Correct |
61 ms |
5224 KB |
Output is correct |
24 |
Correct |
59 ms |
5144 KB |
Output is correct |
25 |
Correct |
62 ms |
5148 KB |
Output is correct |
26 |
Correct |
58 ms |
5052 KB |
Output is correct |
27 |
Correct |
65 ms |
5144 KB |
Output is correct |
28 |
Correct |
59 ms |
5172 KB |
Output is correct |
29 |
Correct |
55 ms |
5324 KB |
Output is correct |
30 |
Correct |
58 ms |
5128 KB |
Output is correct |
31 |
Correct |
58 ms |
5112 KB |
Output is correct |
32 |
Correct |
62 ms |
5168 KB |
Output is correct |
33 |
Correct |
59 ms |
5036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
5072 KB |
Output is correct |
2 |
Correct |
69 ms |
5060 KB |
Output is correct |
3 |
Correct |
59 ms |
5028 KB |
Output is correct |
4 |
Correct |
41 ms |
5016 KB |
Output is correct |
5 |
Correct |
41 ms |
5064 KB |
Output is correct |
6 |
Correct |
52 ms |
5048 KB |
Output is correct |
7 |
Correct |
61 ms |
5164 KB |
Output is correct |
8 |
Correct |
64 ms |
5188 KB |
Output is correct |
9 |
Correct |
61 ms |
5224 KB |
Output is correct |
10 |
Correct |
59 ms |
5144 KB |
Output is correct |
11 |
Correct |
62 ms |
5148 KB |
Output is correct |
12 |
Correct |
58 ms |
5052 KB |
Output is correct |
13 |
Correct |
65 ms |
5144 KB |
Output is correct |
14 |
Correct |
59 ms |
5172 KB |
Output is correct |
15 |
Correct |
55 ms |
5324 KB |
Output is correct |
16 |
Correct |
58 ms |
5128 KB |
Output is correct |
17 |
Correct |
58 ms |
5112 KB |
Output is correct |
18 |
Correct |
62 ms |
5168 KB |
Output is correct |
19 |
Correct |
59 ms |
5036 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
401 ms |
29864 KB |
Output is correct |
35 |
Correct |
433 ms |
30156 KB |
Output is correct |
36 |
Correct |
446 ms |
30028 KB |
Output is correct |
37 |
Correct |
452 ms |
30016 KB |
Output is correct |
38 |
Correct |
440 ms |
30096 KB |
Output is correct |
39 |
Correct |
431 ms |
30188 KB |
Output is correct |
40 |
Correct |
462 ms |
29980 KB |
Output is correct |
41 |
Correct |
418 ms |
30012 KB |
Output is correct |
42 |
Correct |
438 ms |
30160 KB |
Output is correct |
43 |
Correct |
163 ms |
12572 KB |
Output is correct |
44 |
Correct |
160 ms |
17956 KB |
Output is correct |
45 |
Correct |
161 ms |
17932 KB |
Output is correct |
46 |
Correct |
159 ms |
18032 KB |
Output is correct |
47 |
Correct |
444 ms |
30252 KB |
Output is correct |
48 |
Correct |
538 ms |
30332 KB |
Output is correct |
49 |
Correct |
441 ms |
32248 KB |
Output is correct |
50 |
Correct |
394 ms |
33244 KB |
Output is correct |
51 |
Correct |
456 ms |
32728 KB |
Output is correct |
52 |
Correct |
434 ms |
34808 KB |
Output is correct |
53 |
Correct |
443 ms |
33592 KB |
Output is correct |
54 |
Correct |
474 ms |
31452 KB |
Output is correct |
55 |
Correct |
401 ms |
31536 KB |
Output is correct |
56 |
Correct |
398 ms |
31284 KB |
Output is correct |
57 |
Correct |
410 ms |
31308 KB |
Output is correct |
58 |
Correct |
407 ms |
31412 KB |
Output is correct |
59 |
Correct |
407 ms |
31528 KB |
Output is correct |
60 |
Correct |
409 ms |
31516 KB |
Output is correct |
61 |
Correct |
463 ms |
32048 KB |
Output is correct |
62 |
Correct |
471 ms |
31932 KB |
Output is correct |
63 |
Correct |
443 ms |
31824 KB |
Output is correct |