- 1

Challenge Find the code

For her next karate demonstration, Ada will break some bricks. Ada stacked three bricks on top of each other. Initially, their widths (from top to bottom) are W1,W2,W3W1,W2,W3. Ada's strength is SS. Whenever she hits a stack of bricks, consider the largest k≄0k≄0 such that the sum of widths of the topmost kk bricks does not exceed SS; the topmost kk bricks break and are removed from the stack. Before each hit, Ada may also decide to reverse the current stack of bricks, with no cost. Find the minimum number of hits Ada needs in order to break all bricks if she performs the reversals optimally. You are not required to minimise the number of reversals. Input The first line of the input contains a single integer TT denoting the number of test cases. The description of TT test cases follows. The first and only line of each test case contains four space-separated integers SS, W1W1, W2W2 and W3W3. Example Input 3 3 1 2 2 2 1 1 1 3 2 2 1 Example Output 2 2 2

3rd Jan 2020, 1:54 PM
Rohit wadne
1 Answer
+ 2
1) Where is your attempt ? 2) Include the language you're using the tags
3rd Jan 2020, 1:55 PM
Aymane Boukrouh
Aymane Boukrouh - avatar