# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
394951 | Qw3rTy | Rabbit Carrot (LMIO19_triusis) | C++11 | 1 ms | 332 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5+5;
int f[maxN];
int a[maxN];
int b[maxN];
int N,M;
void testIO(){
freopen("../test.in","r",stdin);
return;
}
int LIS(){
deque<int> dp;
for(int i = 1; i <= N; ++i){
if(b[i] > 0)continue;
int pos = lower_bound(dp.begin(),dp.end(),a[i]) - dp.begin();
if(pos == 0)dp.push_front(a[i]);
else dp[pos] = a[i];
}
return dp.size();
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
//testIO();
cin >> N >> M;
for(int i = 1; i <= N; ++i)cin >> a[i];
a[0] = 0;
f[0] = 0;
//O(NlogN)
//find LIS on b[i], where b[i] = a[i] - M*i
for(int i = 1; i <= N; ++i)b[i] = a[i] - M*i;
int res = LIS();
cout << N - res << '\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |