Submission #818172

#TimeUsernameProblemLanguageResultExecution timeMemory
818172trucmaiFinancial Report (JOI21_financial)C++17
48 / 100
4075 ms4964 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const ll N = 3e5+5; ll n,d,a[N],dp[N],mx[N]; //dp[i] = max dp[j] + 1 va (a[i] > a[j] && |i-j| <= D) //wutdahell signed main(){ cin>>n>>d; for(ll i = 1;i <= n;++i) cin>>a[i]; // deque<ll>dq; // for(ll i = 1;i <= n;++i){ // while(!dq.empty() && a[dq.back()] < a[i]) dq.pop_back(); // while(!dq.empty() && dq.front() + d <= i) dq.pop_front(); // dq.push_back(i); // if(i <= d) mx[i] = a[dq.front()]; // } for(ll i = 1;i <= n;++i) dp[i] = 1; for(ll i = n - 1;i >= 1;--i){ ll pos = min(i+d,n); for(ll j = i + 1;j <= pos;++j){ if(a[j] > a[i]) dp[i] = max(dp[i],dp[j] + 1); else pos = min(j + d,n); } } ll res = 0; for(ll i = 1;i <= n;++i) res = max(res,dp[i]); cout<<res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...