제출 #1030664

#제출 시각아이디문제언어결과실행 시간메모리
1030664AcanikolicFinancial Report (JOI21_financial)C++14
0 / 100
4085 ms8276 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define F first #define S second using namespace std; const int N = 1e5 + 10; const int mod = 1e9 + 7; const int inf = 1e15; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n,d; cin >> n >> d; vector<int>a(n + 1); for(int i = 1; i <= n; i++) cin >> a[i]; vector<int>dp(n + 1); for(int i = 1; i <= n; i++) { dp[i] = 1; int mx = 0; for(int j = i - 1; j >= max(1ll,i - d); j--) { if(a[i] > a[j]) dp[i] = max(dp[i],dp[j] + 1); mx = max(mx,a[j]); } for(int j = i - d - 1; j >= 1; j--) { mx = max(mx,a[j]); if(a[i] > mx) dp[i] = max(dp[i],dp[j] + 1); } } int res = 0; for(int i = max(1ll,n - d); i <= n; i++) res = max(res,dp[i]); cout << res; 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...