Submission #1126634

#TimeUsernameProblemLanguageResultExecution timeMemory
1126634Seyyed_Mojtaba_MortazaviGlobal Warming (CEOI18_glo)C++20
100 / 100
89 ms3460 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; const int MAXN = 5e5 + 10; int a[MAXN]; int pl[MAXN]; int main() { int n, x, ans = 0; cin >> n >> x; for (int i = 1; i <= n; i++) cin >> a[i]; vector <int> dp (n, INT_MAX); vector <int> pd (n, INT_MAX); for (int i = 1; i <= n; i++) { int it = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin(); dp[it] = a[i]; pl[i] = it + 1; ans = max(ans, pl[i]); } for (int i = n; i >= 1; i--) { int it = lower_bound(pd.begin(), pd.end(), x - a[i]) - pd.begin(); ans = max(ans, pl[i] + it); it = lower_bound(pd.begin(), pd.end(), -a[i]) - pd.begin(); pd[it] = -a[i]; } cout << ans << endl; }
#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...