제출 #882122

#제출 시각아이디문제언어결과실행 시간메모리
882122skywwlaGlobal Warming (CEOI18_glo)C++17
25 / 100
2089 ms3296 KiB
#include <bits/stdc++.h> using namespace std ; using ll = long long ; const int N = 2e5 + 5 ; int n , x , a[N], l[N], r[N] ; int findLIS() { vector<int> d ; for (int i = 1 ; i <= n ; i++) { auto it = lower_bound(d.begin(), d.end(), a[i]) ; if (it == d.end()) d.push_back(a[i]) ; else *it = a[i] ; } return d.size() ; } int32_t main() { ios::sync_with_stdio(false) ; cin.tie(nullptr) ; cin >> n >> x ; for (int i = 1 ; i <= n ; i++) { cin >> a[i] ; } for (int i = 1 ; i <= n ; i++) { l[i] = a[i] - x ; r[i] = a[i] + x ; } int ret = findLIS() ; if (!x) { cout << ret ; return 0 ; } for (int l = 1 ; l <= n ; l++) { for (int d = -x ; d <= x ; d++) { for (int i = 1 ; i <= l ; i++) { a[i] += d ; } ret = max(ret, findLIS()) ; for (int i = 1 ; i <= l ; i++) { a[i] -= d ; } } } for (int r = n ; r >= 1 ; r--) { for (int d = -x ; d <= x ; d++) { for (int i = r ; i <= n ; i++) { a[i] += d ; } ret = max(ret, findLIS()) ; for (int i = r ; i <= n ; i++) { a[i] -= d ; } } } cout << ret ; 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...