제출 #550771

#제출 시각아이디문제언어결과실행 시간메모리
550771_karan_gandhiRabbit Carrot (LMIO19_triusis)C++17
63 / 100
1076 ms2276 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() #define endl '\n' #define pl(var) " [" << #var << ": " << (var) << "] " #define ll long long void solve() { // get the longest sequence satisfying this int n, h; cin >> n >> h; vector<int> arr(n + 1); for (int i = 1; i <= n; i++) cin >> arr[i]; vector<int> dp(n + 1, 0); dp[0] = 0; for (int i = 1; i <= n; i++) { // dp[i] = 1; // cout << pl(i) << endl; if (i * h >= arr[i]) { dp[i] = 1; } else { continue; } for (int j = i - 1; j >= 1; j--) { // cout << pl(j) << pl(dp[j]) << pl(arr[j]) << endl; if (arr[j] >= arr[i]) { dp[i] = max(dp[i], dp[j] + 1); } else if (arr[j] + (i - j) * h >= arr[i]) { dp[i] = max(dp[i], dp[j] + 1); } } // cout << pl(dp[i]) << endl; } int ans = 0; for (int i = 0; i <= n; i++) ans = max(ans, dp[i]); cout << (n - ans) << endl; } int main() { // freopen(".in", "r", stdin); // freopen(".out", "w", stdout); ios::sync_with_stdio(false); cin.tie(nullptr); int T = 1; // cin >> T; while (T--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...