Submission #674360

#TimeUsernameProblemLanguageResultExecution timeMemory
674360ThinGarfieldGlobal Warming (CEOI18_glo)C++11
100 / 100
107 ms5436 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define mp make_pair #define F first #define S second constexpr int maxn = 2e5 + 10; int n, x; int t[maxn]; int l[maxn]; vector<int> dp; int main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); cin >> n >> x; for (int i = 0; i < n; i++) cin >> t[i]; vector<int> dp(n, INT_MAX); int lis = 0; for (int i = 0; i < n; i++) { int j = lower_bound(dp.begin(), dp.end(), t[i]) - dp.begin(); dp[j] = t[i]; l[i] = j + 1; lis = max(lis, l[i]); } vector<int> dp2(n, INT_MAX); for (int i = n - 1; i >= 0; i--) { int p = lower_bound(dp2.begin(), dp2.end(), x - t[i]) - dp2.begin(); lis = max(lis, l[i] + p); int ins = lower_bound(dp2.begin(), dp2.end(), -t[i]) - dp2.begin(); dp2[ins] = -t[i]; } cout << lis << '\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...