Submission #1109256

#TimeUsernameProblemLanguageResultExecution timeMemory
1109256SalihSahinFinancial Report (JOI21_financial)C++14
48 / 100
4054 ms8288 KiB
#include <bits/stdc++.h> #define pb push_back #define int long long using namespace std; const int mod = 998244353; const int inf = 1e9 + 20; const int N = 1e5+5; int32_t main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int n, d; cin>>n>>d; vector<int> a(n); for(int i = 0; i < n; i++){ cin>>a[i]; } vector<int> dp(n, 1); int ans = 0; for(int i = 0; i < n; i++){ int nxt = min(n-1, i + d); for(int j = i+1; j <= nxt; j++){ if(a[j] <= a[i]) nxt = min(n-1, j+d); } for(int j = i+1; j <= nxt; j++){ if(a[j] > a[i]) dp[j] = max(dp[j], dp[i] + 1); if(a[j] == a[i]) dp[j] = max(dp[j], dp[i]); } ans = max(ans, dp[i]); } cout<<ans<<endl; return 0; }
#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...