Submission #958438

# Submission time Handle Problem Language Result Execution time Memory
958438 2024-04-05T19:19:30 Z shokal_kishan Rabbit Carrot (LMIO19_triusis) C++17
0 / 100
1 ms 432 KB
#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 time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 428 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 428 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 428 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 428 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -