제출 #328364

#제출 시각아이디문제언어결과실행 시간메모리
328364Karen124Global Warming (CEOI18_glo)C++14
28 / 100
4 ms748 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 = 5000 + 10; const ll M = 50; const ll MOD = 1e9 + 7; const ll INF = 1e9 + 10; int n, X, a[N], l[N], r[N], f[N], ans; int main() { cin >> n >> X; int len = 0; for (int i = 0; i < n; i++){ cin >> a[i]; int p = lower_bound(l, l + len, a[i]) - l; l[p] = a[i]; len = max(len, p + 1); f[i] = p + 1; } ans = f[n - 1]; len = 0; for (int i = n - 1; i >= 0; i--){ a[i] *= -1; int p = upper_bound(r, r + len, a[i] - 1) - r; ans = max(ans, f[i] + p); a[i] -= X; p = lower_bound(r, r + len, a[i]) - r; r[p] = a[i]; len = max(len, 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...