제출 #1067516

#제출 시각아이디문제언어결과실행 시간메모리
1067516VMaksimoski008Financial Report (JOI21_financial)C++17
28 / 100
90 ms13908 KiB
#include <bits/stdc++.h> //#define int long long using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int mod = 1e9 + 7; const int LOG = 20; const int maxn = 1e5 + 5; int dp[1000][1000]; signed main() { int n, d; cin >> n >> d; vector<int> v(n+1); set<int> s; for(int i=1; i<=n; i++) cin >> v[i], s.insert(v[i]); vector<int> comp(s.begin(), s.end()); for(int i=1; i<=n; i++) v[i] = lower_bound(comp.begin(), comp.end(), v[i]) - comp.begin(); int m = s.size(); for(int i=1; i<=n; i++) { //prv element dp[i][v[i]] = 1; //make this the new maximum for(int k=i-1; k>=max(1, i-d); k--) for(int j=0; j<v[i]; j++) dp[i][v[i]] = max(dp[i][v[i]], dp[k][j] + 1); //dont make this the new maximum for(int k=i-1; k>=max(1, i-d); k--) for(int j=v[i]; j<m; j++) dp[i][j] = max(dp[i][j], dp[k][j]); } int ans = 0; for(int i=0; i<m; i++) ans = max(ans, dp[n][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...