Page Contents

**Another Frog-Jumping**

**Another Frog-Jumping**

Note: This is an estimated issue. There is no accurate arrangement. You should locate the most ideal arrangement. If you don’t mind investigate the example clarification to guarantee that you comprehend the issue effectively. Likewise, make an effort not to utilize uniquely input, in light of the fact that the checker is specific on experiments to check your entries quicker. Attempt to check your code all alone.

Issue articulation

There are (N+1) stones, numbered (1 , 2 , … , N + 1). For each (i ( 1 ≤ I ≤ N )), the tallness of stone (i) is (h_i) and the estimation of stone (i) is (a_i). There is a frog who is at first on stone 1. He will rehash the accompanying activity some number of times to arrive at stone (N+1) : If the frog is presently on stone (i), he can bounce to the (j) – the stone if the entirety of the accompanying conditions are met:

(i ≤ j ≤ n)

The tallness of the bounce is close to the width of the hop. Here, the stature of the bounce is characterized as a most extreme (h_i , h_{i + 1} , … h_j ), and width as (j − I + 1).

The expense of the bounce is (sumlimits_{l=i}^{j}sumlimits_{r=i(l ne r)}^{j} a_l*a_r).

After, he will consequently go to (j + 1) – the stone.

Likewise, the frog has his fortunate number (k) and he needs to arrive at stone (N+1) in (k) steps so entirety of expenses was limited. Your assignment is to ascertain the base total of expenses for him and find ideal bounces.

Information design

The principal line contains two whole numbers (N) and (k) ((1≤N≤10^4,1≤k≤min(n, 50))) — the length of the clusters and the quantity of hops

The subsequent line contains (N) whole numbers (h_1,h_2,… ,h_n(1≤h_i≤n)) — the exhibit (h)

The third line contains (N) whole numbers (a_1,a_2,… ,a_n(1≤a_i≤10^5)) — the exhibit (a)

It is ensured that we can accomplish (N+1)- th stone in (k) steps.

Yield design

The primary line contains one whole number – the ideal aggregate of expenses. Next (k ) lines contain two numbers – sets (i_1, j_1, . . . i_k, j_k), where (l_1 = 1, r_k = n, i_t ≤ j_t) , and (l_t = r_{t−1} + 1) for all (t>1)– the bounces of the frog.

Decision and scoring :

There are 6 test cases(with test). Your score will be determined by the accompanying standard: for each non-test experiment, you will get (min(20, 20*frac{ja+1}{pa+1})) scores, and 0 scores for the example. Here ja – jury’s whole of costs, dad – your total of expenses. On the off chance that your yield doesn’t concur with the yield design, you will get 0 scores on test.

Test INPUT

10 4

1 3 2 1 2 3 1 2

1

Test OUTPUT

16

1 3

4 5

6 7

8 10

Clarification

We can see that the principal hop from 1 to 3 met the entirety of the previously mentioned conditions. The most extreme in this range is 3, which is close to the width. The expense of this bounce is 6. Presently frog on the fourth stone.

We can see that the main hop from 4 to 5 met the entirety of the previously mentioned conditions. The most extreme in this range is 2, which is close to the width. The expense of this hop is 2. Presently frog on the sixth stone.

We can see that the principal bounce from 6 to 7 met the entirety of the previously mentioned conditions. The greatest in this range is 2, which is close to the width. The expense of this bounce is 2. Presently frog on the eighth stone.

We can see that the primary hop from 8 to 10 met the entirety of the previously mentioned conditions. The most extreme in this range is 3, which is close to the width. The expense of this bounce is 6. Presently frog on the eleventh stone and finish.

Absolutely we have 6+2+2+6=16.

*March Long Challenge 2021 Solutions*

*March Long Challenge 2021 Solutions*

*An Interesting Sequence ISS SOLUTION**Tree House THOUSES SOLUTION**Valid Paths VPATH SOLUTION**Modular Equation MODEQ SOLUTION**Tic Tac Toe TCTCTOE SOLUTION**Xor Equality XOREQUAL SOLUTION**Golf LKDNGOLF SOLUTION**Solubility SOLBLTY SOLUTION*

*April Long Challenge 2021 Solutions*

*April Long Challenge 2021 Solutions*

*Chef and Dice SDICE Solution**Worthy Matrix KAVGMAT Solution**Binary String MEX MEXSTR Solution**Boolean Game BOOLGAME Solution**Tree Permutations TREEPERM Solution**Destroy the EMP Chip CHAOSEMP Solution**Chef and Pair Flips PAIRFLIP Solution**String Power STRPOW Solution**Brahma and Shiva SHRINES Solution**Water Sort Puzzle (Challenge) WTRSORT Solution**World Record BOLT Solution**Strong Language SSCRIPT Solution**Valid Pair SOCKS1 Solution*

*Codechef Long Challenge Solutions*

*Codechef Long Challenge Solutions*

*February Long Challenge 2021*

*February Long Challenge 2021*

#### 1. Frog Sort Solution Codechef

#### 2. Chef and Meetings Solution Codechef

#### 3. Maximise Function Solution Codechef

#### 4. Highest Divisor Solution Codechef

#### 5. Cut the Cake Challenge Solution Codechef

#### 6. Dream and the Multiverse Solution Codechef

#### 7. Cell Shell Solution Codechef

#### 8. Multiple Games Solution Codechef

#### 9. Another Tree with Number Theory Solution Codechef

#### 10. XOR Sums Solution Codechef

#### 11. Prime Game Solution CodeChef

#### 12. Team Name Solution Codechef

### January Long Challenge 2021

**Chef and Division 3 DIVTHREE SOLUTION Code Chef****Encoded String DECODEIT SOLUTION Code Chef****Point Of Impact BILLRD SOLUTION Code Chef****Fair Elections FAIRELCT SOLUTION Code Chef****Watching CPL WIPL SOLUTION Code Chef****Chef and Ants ANTSCHEF SOLUTION Code Chef****Blackjack BLKJK SOLUTION Code Chef****And-Or Game ORAND SOLUTION Code Chef****Stack-Queue Sort (Challenge) SQSORT SOLUTION Code Chef****Expected Number of SCCs RCTEXSCC SOLUTION Code Chef****Curious Matrix CURMAT SOLUTION Code Chef****Cool Subsets COOLSBST SOLUTION Code Chef****Sequence Creation ARCRT SOLUTION Code Chef****Greedy Students GRDSTD SOLUTION Code Chef**

### November Challenge 2020 SOLUTION CodeChef

- Ada and Dishes SOLUTION ADADISH
- Iron Magnet and Wall SOLUTION FEMA2
- Magical Candy Store SOLUTION CNDYGAME
- Unusual Queries SOLUTION UNSQUERS
- Red-Black Boolean Expression SOLUTION RB2CNF
- Chef and the Combination Lock SOLUTION CHEFSSM
- Scalar Product Tree SOLUTION SCALSUM
- Connect on a Grid (Challenge) SOLUTION CONGRID

### October Lunchtime 2020 CodeChef SOLUTIONS

- AND Plus OR SOLUTION ANDOR
- Chef and Subtree MEXs SOLUTION SUBMEXS
- Chef Likes Good Sequences SOLUTION GSUB
- Cute Chef Gift SOLUTION COPAR
- Chef Is Just Throwing Random Words SOLUTION SSO
- Counting Spaghetti SOLUTION CDSUMS
- Chef and Edge Flipping SOLUTION EFLIP

*RELATED :*

- Top Best Keylogger in Python 3 Make One
*What is Hacking?**Secrets of the Deep Dark Web**CODECHEF September Lunchtime 2020 SOLUTIONS**August Lunchtime 2020 SOLUTIONS*

*Related :*

*A. Shandom Ruffle SOLUTION**B. Pear TreaP SOLUTION**C. Sneetches and Speeches 3 SOLUTION**D. The Grim Treaper SOLUTION**Y. Sneetches and Speeches 1 SOLUTION**Z. Trick or Treap SOLUTION**A. Floor Number SOLUTION CODE FORCES**B. Symmetric Matrix SOLUTION CODE FORCES**C. Increase and Copy SOLUTION CODE FORCES**D. Non-zero Segments SOLUTION CODE FORCES**E. Rock, Paper, Scissors SOLUTION CODE FORCES**F. Number of Subsequences SOLUTION CODE FORCES*

*Related :*

*Chef and Easy Queries SOLUTIONS CHEFEZQ**Covid Run SOLUTIONS CVDRUN OCTOBER CHALLENGE**Positive AND SOLUTIONS POSAND**Replace for X SOLUTIONS REPLESX**Village Road Network SOLUTIONS VILLNET**Random Knapsack SOLUTIONS RANDKNAP**D-Dimensional MST SOLUTIONS DDIMMST**Compress all Subsegments SOLUTIONS SEGCOMPR**Adding Squares SOLUTIONS ADDSQURE**Inversions SOLUTIONS INVSMOD2 OCOTBER CHALLENGE**Rooted Minimum Spanning Tree SOLUTIONS ROOTMST*