- 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 Antwoord
+ 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