# MAXWND - Editorial

Setters: awesome_amul sigma_g
Tester: multiple, see announcement
Editorialist: awesome_amul

Hard

# PROBLEM

Given two arrays a and b of size n and m respectively. Find the number of ways to partition the array a into m partitions, such that for the i-th partition, max of its elements is equal to b_i.
Find the bug in the code.

# Explanation

There is no logical bug in this question. The only bug is that the program returns from the solve() function without reading the complete input for the ongoing test case. Because of this the next test case which the program reads contains unread input from the current test case, which leads to wrong input for the next test case, further leading to wrong solution.

# Solution

Setter's Solution
``````2
3 5
1 2 3
5 4 3 2 1
4 2
4 3 2 1
4 3
``````

The correct output for the given test case will be:

``````0
1
``````

The program will read first line of first test case and return from solve(). Next the program will read second line of first test case as input for second test case and again return from solve(). Hence, the program will output:

``````0
0
``````