제출 #805152

#제출 시각아이디문제언어결과실행 시간메모리
805152myst6Financial Report (JOI21_financial)C++14
0 / 100
31 ms8348 KiB
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0)->sync_with_stdio(0); int n, d; cin >> n >> d; vector<int> A(n); for (int i=0; i<n; i++) cin >> A[i]; if (d == 1) { int ans = 1, curr = 1, prev = A[n-1]; for (int i=n-2; i>=0; i--) { if (A[i] < prev) { curr += 1; } else if (A[i] > prev) { curr = 1; } prev = A[i]; ans = max(ans, curr); } cout << ans << "\n"; } else { vector<int> dp(n,1); int ans = 0; for (int i=0; i<n; i++) { for (int j=i-d; j<i; j++) { if (A[j] < A[i]) { dp[i] = max(dp[i], dp[j]+1); } if (A[j] == A[i]) { dp[i] = max(dp[i], dp[j]); } } ans = max(ans, dp[i]); } cout << ans << "\n"; } 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...