Submission #1061742

#TimeUsernameProblemLanguageResultExecution timeMemory
1061742TimDeePeru (RMI20_peru)C++17
0 / 100
1 ms600 KiB
#include "peru.h" #include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("popcnt,avx2") #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 using ll = long long; const int N=2005; ll dp[N]; int solve(int n, int k, int* v){ const int mod = 1e9+7; deque<pi> s; deque<pi> d; ll ans=0; forn(i,n) { if (s.size() && s[0].s<=i-k) s.pop_front(); if (d.size() && d[0].s<=i-k) d.pop_front(); int tmp; while (s.size() && s.back().f <= v[i]) { s.pop_back(); } if (s.size()) { while (d.size() && d.back().s > s.back().s) d.pop_back(); } else { while (d.size()>1) d.pop_back(); } s.pb({v[i],i}); dp[i]=s[0].f; if (i-k>=0) dp[i]+=dp[i-k]; dp[i] = min(dp[i],1ll*v[i]+d.back().f); d.pb({dp[i],i}); ans=(ans*23)%mod; ans=(ans+dp[i])%mod; } return ans; }

Compilation message (stderr)

peru.cpp: In function 'int solve(int, int, int*)':
peru.cpp:26:13: warning: unused variable 'tmp' [-Wunused-variable]
   26 |         int tmp;
      |             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...