This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//IN THE NAME OF GOD
#include<bits/stdc++.h>
#pragma GCC optimize("O2,unroll-loops")
#define endl '\n'
#define F first
#define S second
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fast_io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define file_io freopen("input.in" , "r" , stdin) ; freopen("output.out" , "w" , stdout);
using namespace std;
typedef long long ll;
typedef long double dll;
const int N = 2e5+7;
int a[N], lis[N];
int32_t main(){
fast_io;
int n,x; cin >> n >> x;
for(int i=1; i<=n; i++) cin >> a[i];
lis[n] = n;
for(int i=n-1; i>=1; i--) lis[i] = (a[i] >= a[i+1] ? i : lis[i+1]);
int ans = 0;
a[n+1] = -2e9;
for(int i=1; i<=n; i++){
ans = max(ans,lis[i]-i+1);
if (a[lis[i]+1]+x > a[i]) ans = max(ans,(lis[lis[i]+1])-i+1);
}
cout << ans << endl;
//for(int i=1; i<=n; i++) cout << "hello " << i << " " << lis[i] << endl;
return 0;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |