이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//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... |