Submission #1112864

#TimeUsernameProblemLanguageResultExecution timeMemory
1112864slyceloteRabbit Carrot (LMIO19_triusis)C++17
100 / 100
21 ms3152 KiB
#include <algorithm> #include <cassert> #include <fstream> #include <iostream> #include <string> #include <vector> using namespace std; int main() { cin.tie(0); iostream::sync_with_stdio(false); int n, m; cin >> n >> m; const int NEGINF = -1 - n*m; vector<int> dp(n+2, NEGINF); dp[0] = 1000'000'010; dp[1] = 0; for (int i = 1; i <= n; ++i) { int a; cin >> a; a -= i*m; if (a <= 0) { auto it = upper_bound(dp.begin(), dp.end(), a, greater<>{}); if (it != dp.end()) *it = a; } } for (int i = n+1; i >= 0; --i) if (dp[i] > NEGINF) { cout << n+1-i << endl; break; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...