Submission #575925

#TimeUsernameProblemLanguageResultExecution timeMemory
575925tekiCloud Computing (CEOI18_clo)C++11
0 / 100
1 ms320 KiB
#include <bits/stdc++.h> typedef long long ll; #define pb push_back #define MS(x,y) memset((x),(y),sizeof((x))) #define MN 1000000007 using namespace std; int main() { #if LOCAL_DEBUG fstream cin("in.txt"); #endif ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n,x; cin>>n>>x; int niza[n]; for (int i = 0; i<n; i++) cin>>niza[i]; int dp[n], lisPref[n]; for (int i = 0; i<n; i++) dp[i] = INT_MAX/2; int res = 0; for (int i = 0; i<n; i++) { auto sled = lower_bound(dp,dp+n,niza[i]); int j = sled-dp; dp[j] = niza[i]; lisPref[i] = j+1; res = max(res,lisPref[i]); } for (int i = 0; i<n; i++) dp[i] = INT_MAX/2; for (int i = n-1; i>=0; i--) { auto prev = lower_bound(dp,dp+n,-niza[i]+x); int j = prev-dp; res = max(res,lisPref[i]+j); auto ide = lower_bound(dp,dp+n,-niza[i]); int idePos = ide-dp; dp[idePos] = -niza[i]; } cout<<res<<endl; 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...