Thanks to Max's invaluable leadership, a sizable portion of the ex-convicts are still alive and mentally stable! But before they can return home to their families, Joey orders them to exterminate the bebiliths, even if it costs them their lives!
The bebiliths pour out of the cave, aligned in columns. The columns are aligned such that one bebilith from each column is visible to the ex-convicts. There are bebiliths in the column. Joey commands strategic offenses, during which the ex-convicts eliminate bebiliths from each column for all the columns in .
After every strategic offense from the ex-convicts, Joey wants to evaluate the enemy's condition by finding the strength of the weakest column of bebiliths for all the columns in , and then the same for all the columns in . Help Joey lead the ex-convicts to victory!
This problem can be solved with a brute force solution. As a result, the point value has been lowered to 5 points. If you want to strengthen the data, please send a message to the #problems-in-problems channel on slack.
The first line will contain and , separated by a single space.
The second line will contain integers, with each containing the value .
The next lines will each contain three space-separated integers .
For every strategic offense, print out the number of bebiliths in the weakest column in the range of columns , and the same for the range of columns , separated by a single space.
3 3 4 4 4 1 1 3 2 3 2 1 3 7
1 1 2 1 0 0
- PyPy2/PyPy3: 3s, 30MB
- Java7/Java8: 2s, 30MB