Submission #246311

#TimeUsernameProblemLanguageResultExecution timeMemory
246311SortingGlobal Warming (CEOI18_glo)C++14
15 / 100
2086 ms1536 KiB
#include <bits/stdc++.h> using namespace std; const int k_N = 2e5 + 3; const int k_Inf = 1e9 + 3; int n, x; int t[k_N]; int get_lis(){ vector<int> dp; dp.push_back({-k_Inf}); for(int i = 0; i < n; ++i){ auto it = lower_bound(dp.begin(), dp.end(), t[i]); if(it == dp.end()) dp.push_back(t[i]); else dp[it - dp.begin()] = t[i]; } return (int)dp.size() - 1; } int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> x; for(int i = 0; i < n; ++i) cin >> t[i]; int ans = 0; for(int l = 0; l == 0; ++l){ for(int r = l; r < n; ++r){ for(int d = -x; d <= x; ++d){ for(int i = l; i <= r; ++i) t[i] += d; ans = max(get_lis(), ans); for(int i = l; i <= r; ++i) t[i] -= d; } } } cout << ans << "\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...