Submission #413729

#TimeUsernameProblemLanguageResultExecution timeMemory
413729duyanh1704Rabbit Carrot (LMIO19_triusis)C++14
0 / 100
1 ms204 KiB
#include <iostream> #include <algorithm> #include <vector> using namespace std; const long long inf = 1e16 + 9; int n, res; long long m; long long a[1000005]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; ++i){ long long x; cin >> x; a[i] = 1LL * m * i - x; } vector<long long> f(n + 5, inf); f[0] = -inf; for (int i = 1; i <= n; ++i){ int k = lower_bound(f.begin(), f.end(), a[i]) - f.begin(); res = max(res, k); f[k] = a[i]; } cout << n - res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...