제출 #785199

#제출 시각아이디문제언어결과실행 시간메모리
785199devariaotaGlobal Warming (CEOI18_glo)C++17
15 / 100
2075 ms262144 KiB
#include<bits/stdc++.h> using namespace std; #define ioss ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define int long long #define pii pair<int, int> #define fi first #define se second #define pb push_back int n, x; int arr[200004], dp[200004]; signed main() { ioss; cin >> n >> x; for(int i = 0; i < n; i++) cin >> arr[i]; if(x == 0) { vector<int> tmp; for(int i = 0; i < n; i++) { if(i == 0) { dp[i] = 1; tmp.pb(arr[i]); continue; } if(arr[i] > tmp.back()) dp[i] = dp[i-1]+1, tmp.pb(arr[i]); else { int cur = lower_bound(tmp.begin(), tmp.end(), arr[i])-tmp.begin(); tmp[cur] = arr[i]; dp[i] = dp[i-1]; // for(auto x : tmp) cout << x << " "; // cout << endl; } // cout << " :: " << arr[i] << " " << tmp.back() << " " << dp[i] << endl; } cout << dp[n-1] << endl; return 0; } vector<pii> range; for(int j = 0; j < n; j++) { for(int k = j; k < n; k++) { range.pb({j, k}); } } int ans = 0; for(auto [l, r] : range) { // cout << l << " " << r << endl; for(int k = -x; k <= x; k++) { vector<int> tmp; memset(dp, 0, sizeof(dp)); for(int i = 0; i < n; i++) { if(i == 0) { dp[i] = 1; tmp.pb(arr[i]); continue; } if(i >= l && i <= r) arr[i] += k; if(arr[i] > tmp.back()) dp[i] = dp[i-1]+1, tmp.pb(arr[i]); else { int cur = lower_bound(tmp.begin(), tmp.end(), arr[i])-tmp.begin(); tmp[cur] = arr[i]; dp[i] = dp[i-1]; // for(auto x : tmp) cout << x << " "; // cout << endl; } // cout << " :: " << arr[i] << " " << tmp.back() << " " << dp[i] << endl; if(i >= l && i <= r) arr[i] -= k; ans = max(ans, dp[n-1]); } } } 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...