제출 #744567

#제출 시각아이디문제언어결과실행 시간메모리
744567ajab_01Global Warming (CEOI18_glo)C++17
0 / 100
69 ms11236 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 5; const int INF = 1e9 + 1000; int arr[N] , dp[N] , las[N] , last[N] , g[N] , f[N] , ls[N] , ans , n , x; int32_t main(){ ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); fill(las , las + N , INF); fill(last , last + N , INF); fill(ls , ls + N , INF); cin >> n >> x; for(int i = 0 ; i < n ; i++) cin >> arr[i]; for(int i = 0 ; i < n ; i++){ int low = 0 , high = n; while(high - low > 1){ int mid = (high + low) >> 1; if(las[mid] <= arr[i]) low = mid; else high = mid; } las[low + 1] = arr[i]; dp[i] = low + 1; int l = 0 , r = n; while(r - l > 1){ int mid = (r + l) >> 1; if(last[mid] <= arr[i]) l = mid; else r = mid; } g[i] = l + 1; last[low + 1] = arr[i] - x; } for(int i = 0 ; i < n ; i++){ int low = 0 , high = n; while(high - low > 1){ int mid = (high + low) >> 1; if(ls[mid] <= arr[i]) low = mid; else high = mid; } f[i] = low + 1; f[i] = max(f[i] , g[i]); ls[f[i]] = arr[i]; ans = max(ans , f[i]); } cout << ans << '\n'; 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...