Submission #1025345

#TimeUsernameProblemLanguageResultExecution timeMemory
1025345eysbutnoGlobal Warming (CEOI18_glo)C++17
100 / 100
38 ms4568 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = array<int, 2>; #define all(x) begin(x), end(x) #define sz(x) (int) (x).size() int main() { cin.tie(0) -> sync_with_stdio(0); int n, x; cin >> n >> x; vector<int> a(n); for (int &i : a) { cin >> i; } vector<int> dp, pf(n); int res = 0; for (int i = 0; i < n; i++) { int ind = lower_bound(all(dp), a[i]) - begin(dp); if (ind == sz(dp)) dp.push_back(0); dp[ind] = a[i], pf[i] = ind + 1; res = max(res, pf[i]); } dp.clear(); for (int i = n - 1; i >= 0; i--) { int ind = lower_bound(all(dp), x - a[i]) - begin(dp); res = max(res, pf[i] + ind); ind = lower_bound(all(dp), -a[i]) - begin(dp); if (ind == sz(dp)) dp.push_back(0); dp[ind] = -a[i]; } cout << res << "\n"; }
#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...