Submission #328163

#TimeUsernameProblemLanguageResultExecution timeMemory
328163Karen124Global Warming (CEOI18_glo)C++14
17 / 100
110 ms5356 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int #define F first #define S second #define pb push_back #define md ((b + e) >> 1) #define lc (ind << 1) #define rc (lc | 1) const ll N = 2e5 + 10; const ll LOG = 50; const ll MOD = 1e9 + 7; const ll INF = 1e9 + 10; int n, add, a[N], b[N], ans; pair <int, int> mx[N]; int main() { cin >> n >> add; for (int i = 0; i < n; i++){ cin >> a[i]; } int len = 0; for (int i = 0; i < n; i++){ int p = lower_bound(b, b + len, a[i]) - b; b[p] = a[i]; len = max(len, p + 1); if (i == 0) mx[i] = {p + 1, -a[0]}; else mx[i] = max(mx[i - 1], {p + 1, -a[i]}); } ans = len; fill(b, b + n + 1, 0); len = 0; for (int i = n - 1; i >= 0; i--){ int p = lower_bound(b, b + len, -(a[i] + add)) - b; b[p] = -(a[i] + add); len = max(len, p + 1); if (i && a[i - 1] < a[i] + add){ ans = max(ans, mx[i - 1].F + p + 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...