Submission #960616

#TimeUsernameProblemLanguageResultExecution timeMemory
960616HossamHero7Global Warming (CEOI18_glo)C++14
28 / 100
2090 ms3928 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' const int N = 2e5 + 5; int dp[N][2]; void solve(){ ll n,x; cin>>n>>x; vector<ll> v(n); for(int i=0;i<n;i++) cin>>v[i]; for(int i=n-1;i>=0;i--){ for(int j=0;j<2;j++){ for(int k=i+1;k<n;k++){ if(v[k] > v[i]){ dp[i][j] = max(dp[i][j] , dp[k][j] + 1); } } if(!j){ for(int k=i+1;k<n;k++){ if(v[k] > v[i]-x){ dp[i][j] = max(dp[i][j] , dp[k][1] + 1); } } } } } int ans = 0; for(int i=0;i<n;i++){ ans = max(ans, dp[i][0] + 1); } cout<<ans<<endl; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; //cin>>t; while(t--){ solve(); } 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...
#Verdict Execution timeMemoryGrader output
Fetching results...