제출 #885676

#제출 시각아이디문제언어결과실행 시간메모리
885676Iliya_Global Warming (CEOI18_glo)C++14
0 / 100
17 ms3920 KiB
//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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...