Submission #1021751

#TimeUsernameProblemLanguageResultExecution timeMemory
1021751ef10Global Warming (CEOI18_glo)C++17
100 / 100
82 ms6284 KiB
// Source: https://usaco.guide/general/io #include <bits/stdc++.h> using namespace std; #define LL long long LL N, X; LL A[200005]; LL PR[200005]; LL dp[200005]; int main() { cin >> N >> X; for (int i = 1; i <= N; i++) { cin >> A[i]; } LL res = 0; dp[1] = A[1]; LL E = 2; for (int i = 2; i <= N; i++) { int ind = lower_bound(dp+1,dp+E,A[i])-dp; PR[i]=ind; res = max(res,PR[i]); dp[ind] = A[i]; if (ind==E) { E++; } } dp[1]=-A[N]; E=2; for (int i = N-1; i>=1; i--) { int ind = lower_bound(dp+1,dp+E,X-A[i])-dp; res = max(res,PR[i]+ind-1); ind = lower_bound(dp+1,dp+E,-A[i])-dp; dp[ind]=-A[i]; if (ind == E) { E++; } } cout << res << 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...