Submission #483331

#TimeUsernameProblemLanguageResultExecution timeMemory
483331BERNARB01Global Warming (CEOI18_glo)C++17
25 / 100
95 ms3688 KiB
#include <bits/stdc++.h> using namespace std; const int N = (int) 2e5 + 9; const int inf = (int) 1e9 + 9; int n, x, a[N], lis_dp[N], brute_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; 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); } if (x == 0) { cout << ans << '\n'; return 0; } if (n * 1LL * n * 1LL * n * 2LL * x <= (int) 2e8) { for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { for (int k = -x; k <= x; k++) { fill(brute_dp, brute_dp + n, inf); for (int ii = 0; ii < n; ii++) { int jj = lower_bound(brute_dp, brute_dp + n, a[ii] + (i <= ii && ii <= j) * x) - brute_dp; brute_dp[jj] = a[ii] + (i <= ii && ii <= j) * x; ans = max(ans, jj + 1); } } } } cout << ans << '\n'; return 0; } if (n <= 1000) { for (int i = n - 1; i >= 0; i--) { a[i] += x; fill(brute_dp, brute_dp + n, inf); for (int ii = 0; ii < n; ii++) { int jj = lower_bound(brute_dp, brute_dp + n, a[ii]) - brute_dp; brute_dp[jj] = a[ii]; ans = max(ans, jj + 1); } } cout << ans << '\n'; return 0; } 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...