Submission #958426

#TimeUsernameProblemLanguageResultExecution timeMemory
958426shokal_kishanRabbit Carrot (LMIO19_triusis)C++17
0 / 100
1 ms348 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; int pr=arr[0]; if(pr>m) { ans++; pr=m; } for(int i=1;i<n;i++){ if(arr[i]-pr>m) ans++,pr=LLONG_MAX; else pr = arr[i]; } 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...