import java.util.*; public class c { Scanner in=new Scanner(System.in); public static void main(String[] args) { new c().go(); } private void go() { int n=in.nextInt(),d=in.nextInt(); int[] p=new int[n+1]; for(int i=0;i=0;i--){//price with no dividers is just price of remaining items total+=p[i]; dp[i][0]=round(total); } for(int i=1;i<=d;i++)for(int j=0;j<=n;j++){//for this number of items remaining int sum=0; dp[j][i]=Integer.MAX_VALUE; for(int k=j;k<=n;k++){ dp[j][i]=Math.min(dp[j][i], round(sum)+dp[k][i-1]);//simulate placing the divider at every location sum+=p[k]; } } System.out.println(dp[0][d]); } private int round(int total) { int mod=total%10; if(mod<5)return total-mod; return total-mod+10; } } //cent savings //with so many products and dividers checking out rounding to nearest 10, figure out least amount of money //dp