Submission #483754

#TimeUsernameProblemLanguageResultExecution timeMemory
483754duchungFinancial Report (JOI21_financial)C++17
0 / 100
4038 ms2628 KiB
#pragma GCC optimize("O3") #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> using namespace std; const int N = 3e5 + 5; int n , d; int a[N]; int dp[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> d; for (int i = 1 ; i <= n ; ++i) cin >> a[i]; for (int i = 1 ; i <= n ; ++i) { dp[i] = 1; for (int j = i - 1 ; j >= max(i - d , 1) ; --j) { if (a[i] > a[j]) dp[i] = max(dp[i] , dp[j] + 1); else dp[i] = max(dp[i] , dp[j]); } } int ans = 0; for (int i = 1 ; i <= n ; ++i) ans = max(ans , dp[i]); cout << ans; }
#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...