Cut number in optimal way

Revision en1, by Vasiljko, 2018-01-29 20:32:03

Given string S of N (N<=100 000) characters (each character is digit). Also given, L and R (L <= R<= 109 ). Find maximum sum that is possible to obtain cutting the string in such a way that every part has value <=R and >=L.

Input: N L R S

Test case:
8 13 997
81196054

Output: 1825

Explanation: These are all possible cuts. Last cut is best
1. 81|19|60|54
2. 81|196|054
3. 811|96|054
4. 811|960|54

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Vasiljko 2018-01-29 21:22:02 1 Tiny change: ' R (L <= R<= $10^9$ ' -> ' R (L <= R <= $10^9$ '
en1 English Vasiljko 2018-01-29 20:32:03 514 Initial revision (published)