제출 #532251

#제출 시각아이디문제언어결과실행 시간메모리
532251HaYoungJoonGlobal Warming (CEOI18_glo)C++14
0 / 100
43 ms5256 KiB
#include <bits/stdc++.h> using namespace std; int n, X, a[200001], res1[200001], res2[200001], L[200001]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> X; for (int i = 1; i <= n; i++) cin >> a[i]; int lis = 0; for (int i = n; i >= 1; i--) { int pos = upper_bound(L,L + lis, a[i]) - L; L[pos] = a[i]; res1[i] = pos + 1; lis = max(lis, pos + 1); } for (int i = 1; i <= n; i++) a[i] -= X; memset(L,0,sizeof L); lis = 0; for (int i = 1; i <= n; i++) { int pos = upper_bound(L,L + lis, a[i]) - L; L[pos] = a[i]; res2[i] = pos + 1; lis = max(lis, pos + 1); } int res = 0; for (int i = 1; i < n; i++) res = max(res,res1[i] + res2[i+1]); cout << res; 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...