Submission #1164762

#TimeUsernameProblemLanguageResultExecution timeMemory
1164762Ghulam_JunaidRabbit Carrot (LMIO19_triusis)C++20
14 / 100
53 ms328 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n, m; cin >> n >> m; ll ans = 0; ll dp[n + 5] = {}; for (ll i = 1; i <= n; i ++){ ll x; cin >> x; ll ind = -1; for (ll j = ans; j <= n; j ++){ if (dp[j] + m >= x){ ind = j; break; } } for (ll j = ans + 1; j <= n; j ++) dp[j] = dp[j - 1] + m; if (ind == ans) dp[ind] = x; else{ if (ind != -1) dp[ind] = max(dp[ind], x); ans++; } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...