Can You Please give the hint to solve this problem

Can You Please give the hint to solve this problem
https://codeforces.com/problemset/problem/499/A

hello @cbcao263
this is a simple while loop problem.

start iterating from 1 .till the last important portion of movie (i.e rn)

now if current…current+x is not a part of best moment then take x step.
otherwise increment by one.

#include <cstdio>

int main()
{
    int no_of_interesting_portions, skip_step;
    scanf("%d %d", &no_of_interesting_portions, &skip_step);
 
    int current_minute = 1, no_of_watched_minutes = 0;
    for(int i = 1; i <= no_of_interesting_portions; i++)
    {
        int beginning_i, end_i;
        scanf("%d %d", &beginning_i, &end_i);
 
 
        no_of_watched_minutes += (beginning_i - current_minute)%skip_step + (end_i - (beginning_i - 1));
 
        current_minute = end_i + 1;
    }
 
    printf("%d\n", no_of_watched_minutes);
    return 0;
}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.