@@ -0,0 +1,771 @@
+// http://codeforces.com/problemset/problem/1011/A%0A%0Aimport java.util.Arrays;%0Aimport java.util.Scanner;%0A%0Apublic class Solution %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09Scanner read = new Scanner(System.in);%0A%09%09%0A%09%09int n = read.nextInt();%0A%09%09int k = read.nextInt();%0A%09%09%0A%09%09// Clear buffer%0A%09%09read.nextLine();%0A%09%09%0A%09%09char%5B%5D s = read.nextLine().toCharArray();%0A%09%09Arrays.sort(s);%0A%0A%09%09int minWeight = (s%5B0%5D - 'a') + 1;%09%0A%09%09k--;%0A%09%09for (int i = 1, j = 0; i %3C n; ++i) %7B%0A%09%09%09if (k == 0) %7B%0A%09%09%09%09break;%0A%09%09%09%7D%0A%09%09%09int currentLetterWeight = (s%5Bi%5D - 'a') + 1;%0A%09%09%09if (s%5Bi%5D - s%5Bj%5D %3E= 2) %7B%0A%09%09%09%09minWeight += currentLetterWeight;%0A%09%09%09%09k--;%0A%09%09%09%09j = i;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09if (k == 0) %7B%0A%09%09%09System.out.println(minWeight);%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09System.out.println(%22-1%22);%0A%09%09%7D%0A%0A%09%09// Close scanner%0A%09%09read.close();%0A%09%7D%0A%0A%7D%0A

Create Stages.java