Submission #490689

#TimeUsernameProblemLanguageResultExecution timeMemory
490689PacifiedPenguinRabbit Carrot (LMIO19_triusis)C++17
100 / 100
29 ms8160 KiB
#include <bits/stdc++.h> #define int long long using P = std::pair<int, int>; int32_t main() { std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0); int N, M; std::cin >> N >> M; std::vector<int> a(N + 1); std::vector<P> b(N + 1), lis(N); int ans = 0; for(int i = 1; i <= N; i++){ std::cin >> a[i]; b[i].first = -(a[i] - M * i); b[i].second = i; if(a[i] > M * i) continue; auto be = lis.begin(); auto e = lis.begin() + ans; auto it = std::lower_bound(be, e, b[i]); if(it == e){ lis[ans++] = b[i]; }else{ *it = b[i]; } } std::cout << N - ans << '\n'; 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...