Submission #714438

#TimeUsernameProblemLanguageResultExecution timeMemory
714438FedShatFinancial Report (JOI21_financial)C++17
48 / 100
4011 ms6972 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr int INF = numeric_limits<int>::max() / 2; constexpr ll INFLL = numeric_limits<ll>::max() / 2; template<class T> istream &operator>>(istream &is, vector<T> &a) { for (auto &i : a) { is >> i; } return is; } int main() { cin.tie(0)->sync_with_stdio(0); #ifdef __APPLE__ freopen("input.txt", "r", stdin); #endif int n, d; cin >> n >> d; vector<int> a(n); cin >> a; vector<int> dp(n), ri(n); for (int i = 0; i < n; ++i) { dp[i] = 1; ri[i] = i; for (int j = 0; j < i; ++j) { if (i - ri[j] <= d && a[j] < a[i]) { dp[i] = max(dp[i], dp[j] + 1); } } for (int j = 0; j <= i; ++j) { if (i - ri[j] <= d && a[i] <= a[j]) { ri[j] = i; } } } int ans = 0; for (int i = 0; i < n; ++i) { if (ri[i] == n - 1) { ans = max(ans, dp[i]); } } cout << ans << "\n"; }
#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...