Submission #1103266

#TimeUsernameProblemLanguageResultExecution timeMemory
1103266coolboy19521Global Warming (CEOI18_glo)C++17
100 / 100
79 ms5456 KiB
#include "bits/stdc++.h" using namespace std; const int inf = 1e9 + 7; int main() { int n, x; cin >> n >> x; vector<int> t(n + 1); for (int i = 1; i <= n; i ++) { cin >> t[i]; } vector<int> v(n, inf); vector<int> dp(n + 1); int r = 0; for (int i = 1; i <= n; i ++) { int j = lower_bound(begin(v),end(v),t[i]) - begin(v); v[j] = t[i]; dp[i] = j + 1; r = max(r, dp[i]); } v = vector<int>(n, inf); for (int i = n; 0 < i; i --) { int j = lower_bound(begin(v),end(v),-t[i] + x) - begin(v); r = max(r, dp[i] + j); j = lower_bound(begin(v),end(v),-t[i]) - begin(v); v[j] = -t[i]; } cout << r << '\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...