제출 #483350

#제출 시각아이디문제언어결과실행 시간메모리
483350BERNARB01Global Warming (CEOI18_glo)C++17
62 / 100
62 ms6564 KiB
#include <bits/stdc++.h> using namespace std; const int N = (int) 3e5 + 9; const long long inf = (long long) 1e18L; long long n, x, a[N], dp[N]; pair<long long, long long> suffix_lds_info[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> x; for (int i = 0; i < n; i++) { cin >> a[i]; } long long ans = 1; fill(dp, dp + n, inf); for (long long i = n - 1; i >= 0; i--) { long long j = lower_bound(dp, dp + n, -a[i]) - dp; dp[j] = -a[i]; ans = max(ans, j + 1); suffix_lds_info[i] = {ans, -dp[ans - 1]}; } fill(dp, dp + n, inf); for (long long i = 0; i < n; i++) { a[i] -= x; long long j = lower_bound(dp, dp + n, a[i]) - dp; dp[j] = a[i]; if (i + 1 < n) { long long ns = suffix_lds_info[i + 1].second; long long sl = suffix_lds_info[i + 1].first; j = lower_bound(dp, dp + n, ns) - dp; j -= 1; ans = max(ans, j + 1 + sl); } } 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...