# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
503837 | zhangjishen | Rabbit Carrot (LMIO19_triusis) | C++98 | 38 ms | 4628 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;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
template<typename T> bool chkmin(T &a, T b){return b < a ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return b > a ? a = b, 1 : 0;}
typedef long long ll;
const int MAXN = 2e5 + 10;
int n, m, h[MAXN], g[MAXN], f[MAXN];
int main(){
scanf("%d %d", &n, &m);
for(int i = 1; i <= n; i++){
scanf("%d", &h[i]);
g[i] = h[i] - i * m;
}
g[0] = 0;
// LIS
for(int i = 1; i <= n + 1; i++)
f[i] = 2e9;
int j;
for(int i = n; i >= 0; i--){
j = upper_bound(f + 1, f + 2 + n, g[i]) - f;
f[j] = g[i];
}
printf("%d\n", n + 1 - j);
}
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... |