제출 #811710

#제출 시각아이디문제언어결과실행 시간메모리
811710vjudge1Financial Report (JOI21_financial)C++17
48 / 100
1449 ms100604 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int n, d; int a[(int)3e5 + 10]; const int N = 7e3 + 10; bool f[N][N]; int main() { ios::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++) { int lst = i; bool flag = 1; for(int j = i + 1; j <= n; j++) { if(!flag) break; if(j - lst <= d) f[i][j] = 1; if(a[j] <= a[i]) flag &= (j - lst <= d), lst = j; } } vector<int> dp(n + 1, 1); dp[1] = 1; for(int i = 1; i <= n; i++) { for(int j = i + 1; j <= n && f[i][j]; j++) if(a[j] > a[i]) dp[j] = max(dp[j], dp[i] + 1); } int res = 0; for(int 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...