Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class problemOne {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int wordsCount = scanner.nextInt();
- int minWeight=Integer.MAX_VALUE;
- String word = " ";
- int score = 0;
- for (int i = 0; i < wordsCount; i++) {
- word = scanner.next();
- for(int j = 0; j < word.length(); j++){
- //score += word.toLowerCase().charAt(j) - 'a' + 1;
- char letter = word.charAt(j);
- int asc = (int) letter - 96;
- score+=asc ;
- }
- if(score<=minWeight){
- minWeight=score;
- }
- }
- System.out.printf("%d %s",score,word);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement