Submission #419998

#TimeUsernameProblemLanguageResultExecution timeMemory
419998davi_bartFinancial Report (JOI21_financial)C++17
48 / 100
4048 ms5132 KiB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define fi first
#define se second
#define ld long double
#define pb push_back
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int N,D;
vector<int> v;
int memo[300010];
signed main(){
	ios::sync_with_stdio(false);cin.tie(0);
    cin>>N>>D;
    v.pb(0);
    for(int i=0;i<N;i++){
        int a;cin>>a;
        v.pb(a);
    }
    int ans=0;
    for(int i=1;i<=N;i++){
        int cur=0;
        memo[i]=1;
        for(int j=i-1;j>=0;j--){
            if(v[j]>=v[i])cur++;
            if(cur>=D)break;
            if(v[j]<v[i]){
                cur=0;
                memo[i]=max(memo[i],memo[j]+1);
            }
        }
        ans=max(ans,memo[i]);
        //cout<<memo[i]<<" ";
    }
    //cout<<endl;
    cout<<ans<<endl;

}
#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...