Submission #1096682

#TimeUsernameProblemLanguageResultExecution timeMemory
1096682nguyenvuGlobal Warming (CEOI18_glo)C++14
10 / 100
2067 ms5516 KiB
#include<bits/stdc++.h> #define ll long long #define endl "\n" #define FILE "DAYDEP" using namespace std; int n,x; ll a[200005],dp[200005]; void sub2() { for(int i=1;i<=n;i++) dp[i]=10000000000; int ans=0; for(int i=1;i<=n;i++){ int k=lower_bound(dp+1,dp+n+1,a[i])-dp; dp[k]=a[i]; ans=max(ans,k); } cout<<ans; } void solve() { int ans=0; for(int i=1;i<n;i++){ int cnt=1; ll mx=-1e9; int d=0; for(int j=i+1;j<=n;j++){ if(a[j]>a[i]){ cnt++; mx=max(mx,a[i]); } else{ int dem=0; if(a[j]+x<=mx) continue; for(int k=j+1;k<=n;k++){ if(a[k]+x>mx) mx=a[k],dem++; } mx=a[j]; d=max(d,dem); } } cnt+=d; ans=max(d,ans); } cout<<ans; } int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); //freopen(FILE".inp","r",stdin); //freopen(FILE".out","w",stdout); cin>>n>>x; for(int i=1;i<=n;i++) cin>>a[i]; if(x==0) sub2(); else solve(); }
#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...