Submission #197853

#TimeUsernameProblemLanguageResultExecution timeMemory
197853tunaGlobal Warming (CEOI18_glo)C++11
10 / 100
63 ms2748 KiB
#include "bits/stdc++.h" using ll = long long; using namespace std; const int N = 2e5 + 1, mod = 1e9 + 7; int n, x, ans = 0, a[N], f[2][N]; int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> x; for (int i = 1; i <= n; i++) { cin >> a[i]; f[0][i] = f[1][i] = INT_MAX; } f[0][0] = f[1][0] = -INT_MAX; for (int i = 1; i <= n; i++) { int k = lower_bound(f[1] + 1, f[1] + n + 1, a[i]) - f[1]; f[1][k] = a[i]; ans = max(ans, k); if (i == 1) continue; k = lower_bound(f[0] + 1, f[0] + n + 1, a[i - 1] - x) - f[0]; f[0][k] = a[i - 1] - x; f[1][k] = min(f[1][k], f[0][k]); ans = max(ans, k); } cout << ans; }
#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...