Submission #998900

#TimeUsernameProblemLanguageResultExecution timeMemory
998900niwradRabbit Carrot (LMIO19_triusis)C++17
100 / 100
58 ms3932 KiB
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; int main() { //freopen("cowjog.in", "r", stdin); //freopen("cowjog.out", "w", stdout); int n, m; cin >> n >> m; vector<int> vec(n); for (int i = 0; i < n; i++) { int a; cin >> a; a -= (i + 1) * m; a *= -1; vec[i] = a; } vector<int> dp(n + 1, 1e9 + 7); dp[0] = -1e9 - 7; for (int i = 0; i < n; i++) { if (vec[i] < 0) { continue; } int l = (int) (upper_bound(dp.begin(), dp.end(), vec[i]) - dp.begin()); dp[l] = vec[i]; } int max = 0; for (int l = 0; l <= n; l++) { if (dp[l] != 1e9 + 7) { max = l; } } cout << n - max << "\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...