Little Shino and Contests
Practice
2.4 (13 votes)
Algorithms
Approved
Dynamic programming
Easy
Problem
86% Success 1934 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Given two array A and B of length 5. You have 5 problems to solve in a contest. For \(i^{th}\) problem you need exactly \(A_i\) minutes to solve. But you can't concentrate on \(i^{th}\) problem for more than \(B_i\) minutes continuously. Find number of ways to schedule the \(\sum_{i=1}^{5}A_i\) minutes so that you will solve all the 5 problems (mod \(10^9 + 7\))? Scheduling means for each minute, you have to decide on which problem you will concentrate during that minute.

Two schedules are considered different if at-least for one of the \(\sum_{i=1}^{5}A_i\) minutes, you are concentrating on different problems in both the schedules.

Input Format:
First line contains 5 space separated integers, denoting \(A_i\) \((1 \le A_i \le 10)\). Second line contains 5 space separated integers, denoting \(B_i\) \((1 \le B_i \le 10)\).

Output Format:
Find number of ways to schedule the \(\sum_{i=1}^{5}A_i\) minutes so that you will solve all the 5 problems (mod \(10^9 + 7\))

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
8 votes
Tags:
Easy
Points:30
13 votes
Tags:
Dynamic ProgrammingAlgorithmsIntroduction to Dynamic Programming 1
Points:30
12 votes
Tags:
Binary SearchDynamic ProgrammingEasy