-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodeCrazyMinions.java
44 lines (31 loc) · 940 Bytes
/
CodeCrazyMinions.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package problems.codechef;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Created by arpit on 3/1/17.
*/
public class CodeCrazyMinions {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t;
char[]ch;
t=Integer.parseInt(br.readLine());
while (t-->0){
ch=br.readLine().toCharArray();
System.out.println(solve(ch,ch.length));
}
}
private static String solve(char[] ch, int l) {
int cnt=2;
for (int i = 1 ; i <l ; i++) {
if (ch[i]==ch[i-1])cnt++;
else if (ch[i]>ch[i-1])cnt+=ch[i]-ch[i-1]+1;
else cnt+='z'-ch[i-1]+1+ch[i]-'a'+1;
//
}
System.out.println(cnt);
if (cnt<=(11*l)) return "YES";
return "NO";
}
}