• + 0 comments
    def workbook(n, k, arr):
        # Write your code here
        
        current_page_no = 0
        special_problem_count = 0
        for chapter in range(1, n+1):
            pages = math.ceil(arr[chapter-1] / k)
            current_problems = 0
            while pages > 0:
                current_page_no += 1
                problems_on_current_page = k if (arr[chapter-1] - current_problems) > k else arr[chapter-1] - current_problems
                if current_page_no > current_problems and current_page_no <= (current_problems+problems_on_current_page):
                    special_problem_count += 1
                current_problems += problems_on_current_page
                pages -= 1            
        return special_problem_count