Submission #958438

#TimeUsernameProblemLanguageResultExecution timeMemory
958438shokal_kishanRabbit Carrot (LMIO19_triusis)C++17
0 / 100
1 ms432 KiB
#include<bits/stdc++.h> using namespace std; #define int long long vector<vector<int>>gr; vector<int>ans; int f(int ind){ int sm=0; for(auto x:gr[ind]){ sm+=f(x)+1; } ans[ind]=sm; return sm; } int lcs(vector<int>arr1,vector<int>arr2){ int n=arr1.size(); int m=arr2.size(); vector<vector<int>>dp(2,vector<int>(m+1,0)); for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ dp[1][j]=max(dp[0][j],dp[1][j-1]); int tm = dp[0][j-1]; if(arr1[i-1]==arr2[j-1])tm++; dp[1][j]=max(tm,dp[1][j]); } dp[0]=dp[1]; } return dp[0][m]; } int32_t main(){ int n,m;cin>>n>>m; vector<int>arr(n),arr2(n),v; for(int i=0;i<n;i++) cin>>arr[i]; int ans=0; if(arr[0]<=m){ int pr=0; for(int i=0;i<n;i++){ if(arr[i]-pr>m) ans++,pr=LLONG_MAX; else pr=arr[i]; } } else{ arr[0]=m; ans++; for(int i=0;i<n-1;i++){ if(arr[i+1]-arr[i]>m) ans++,arr[i+1]=arr[i]+m; } } cout<<ans<<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...