# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
944204 | Sunbae | Rabbit Carrot (LMIO19_triusis) | C++17 | 45 ms | 6196 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;
using ll = long long;
const int N = 2e5 + 5;
ll a[N];
vector<ll>C;
int m, bit[N];
void upd(int i, int val){
for(; i<=m; i+=i&-i) bit[i] = max(bit[i], val);
}
int qry(int i){
int res = 0;
for(; i; i-=i&-i) res = max(res, bit[i]);
return res;
}
int pos(ll x){
return upper_bound(C.begin(), C.end(), x) - C.begin();
}
signed main(){
int n; ll M; scanf("%d %lld", &n, &M);
for(int i = 1; i<=n; ++i) scanf("%lld", a+i), C.push_back(M*i - a[i]);
sort(C.begin(), C.end()); C.resize(unique(C.begin(), C.end()) - C.begin()); m = C.size();
int LIS = 0;
for(int i = 1; i<=n; ++i){
ll b = M*i - a[i];
if(b >= 0){
int ind = pos(b), T = qry(ind) + 1;
LIS = max(T, LIS);
upd(ind, T);
}
}
printf("%d", n - LIS);
}
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... |