Submission #890291

#TimeUsernameProblemLanguageResultExecution timeMemory
890291toastifishiRabbit Carrot (LMIO19_triusis)C++14
100 / 100
22 ms5084 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, m; cin >> n >> m; vector <int> a(n + 1), b(n + 1); for(int i = 1; i <= n; i++) { cin >> a[i]; b[i] = m * i - a[i]; } vector <int> lis; for(int i = 1; i <= n; i++) { if(b[i] < 0) continue; if(lis.empty() || lis.back() <= b[i]) lis.push_back(b[i]); else { int ii = upper_bound(lis.begin(), lis.end(), b[i]) - lis.begin(); lis[ii] = b[i]; } } cout << n - (int)lis.size() << "\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...