제출 #483335

#제출 시각아이디문제언어결과실행 시간메모리
483335BERNARB01Global Warming (CEOI18_glo)C++17
0 / 100
2 ms460 KiB
#include <bits/stdc++.h> using namespace std; const int N = (int) 2e3 + 9; const int inf = (int) 1e9 + 9; long long n, x, a[N], lis_dp[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> x; for (int i = 0; i < n; i++) { cin >> a[i]; } int ans = 1; for (int ii = n - 1; ii >= 0; ii--) { a[ii] += x; fill(lis_dp, lis_dp + n, inf); for (int i = 0; i < n; i++) { int j = lower_bound(lis_dp, lis_dp + n, a[i]) - lis_dp; lis_dp[j] = a[i]; ans = max(ans, j + 1); } } for (int ii = 0; ii < n; ii++) { a[ii] -= 2 * x; fill(lis_dp, lis_dp + n, inf); for (int i = 0; i < n; i++) { int j = lower_bound(lis_dp, lis_dp + n, a[i]) - lis_dp; lis_dp[j] = a[i]; ans = max(ans, j + 1); } } 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...