Submission #532258

#TimeUsernameProblemLanguageResultExecution timeMemory
532258HaYoungJoonGlobal Warming (CEOI18_glo)C++14
0 / 100
52 ms4144 KiB
#include <bits/stdc++.h> using namespace std; int n, X, a[200001], b[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]; b[i] = a[i]; } reverse(b+1,b+1+n); int lis = 0; for (int i = 1; i <= n; i++) { int pos = upper_bound(L,L + lis, b[i]) - L; L[pos] = b[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...