# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
483747 |
2021-11-01T02:30:14 Z |
kawaii |
Peru (RMI20_peru) |
C++14 |
|
1 ms |
468 KB |
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma,bmi,bmi2")
#include <bits/stdc++.h>
using namespace std;
//define int long long
long long mod = 1e9 + 7, ans = 0;
int n, m, k, a[2500005], l2[2500005], mx[2500005][22], twt[2500005];
deque<pair<int, int> > dq;
int solve(int n, int k, int* a){
twt[0] = 1;
for(int i = 1; i <= n; i++){
if(i >= 2) l2[i] = l2[i / 2] + 1;
mx[i][0] = a[i];
twt[i] = ((long long) twt[i - 1] * (long long) 23) % mod;
}
for(int i = 0; i <= n; i++){
for(int j = 1; i + (1 << (j - 1)) <= n; j++){
mx[i][j] = max(mx[i][j - 1], mx[i + (1 << (j - 1))][j - 1]);
}
}
dq.push_back(make_pair(0, 0));
for(int i = 1; i <= n; i++){
if(dq.size() == 0){
dq.push_back(make_pair(a[i], i));
ans = (ans + (long long) a[i] * twt[n - i]) % mod;
}
else{
int q = dq.front().first;
pair<int, int> t;
while(dq.size() > 0 && dq.front().first == q){
t = dq.front();
dq.pop_front();
}
dq.push_front(t);
while(dq.size() > 0 && i - dq.front().second > k) dq.pop_front();
t = dq.front();
int c = l2[i - t.second];
dq.push_back(make_pair(((long long) t.first + max(mx[t.second][c], mx[i - (1 << c) + 1][c])) % mod, i));
ans = (ans + (long long) dq.back().first * twt[n - i]) % mod;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |