Advertisement
Ruhan_DIU

Chef and Typing

Oct 19th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. import java.io.*;
  2. import java.math.*;
  3. import java.security.*;
  4. import java.text.*;
  5. import java.util.*;
  6. import java.util.concurrent.*;
  7. import java.util.regex.*;
  8.  
  9. public class Main {
  10.  
  11. public static void main(String[] args) {
  12. Scanner in = new Scanner(System.in);
  13.  
  14. int m=in.nextInt();
  15. for (int n = 1; n <=m ; n++) {
  16. int x=in.nextInt();
  17. String[] word=new String[x];
  18. double[] time=new double[x];
  19.  
  20. int k=-1;
  21.  
  22. for (int i = 0; i <x; i++) {
  23. String w=in.next();
  24. int count=0,pos=0;
  25. for (int j = 0; j < x; j++) {
  26. if(w.equalsIgnoreCase(word[j])){
  27. count++;
  28. pos=j;
  29. break;
  30. }
  31. }
  32.  
  33. if(count==0){
  34. double sum=0.2;
  35. for (int p = 1; p <w.length() ; p++) {
  36. char c=w.charAt(p);
  37. if(c=='d'||c=='f'){
  38. char cc=w.charAt(p-1);
  39. if(cc=='d'|| cc=='f'){
  40. sum=sum+0.4;
  41. }else{
  42. sum=sum+0.2;
  43. }
  44. }
  45. else if(c=='j'|| c=='k'){
  46. char cp=w.charAt(p-1);
  47. if(cp=='j'|| cp=='k'){
  48. sum=sum+0.4;
  49. }else{
  50. sum=sum+0.2;
  51. }
  52. }
  53. }
  54. k++;
  55. word[k]=w;
  56. time[k]=sum;
  57. }
  58.  
  59. else if(count!=0){
  60. double v=time[pos];
  61. v=v/2;
  62. k++;
  63. word[k]=w;
  64. time[k]=v;
  65. }
  66.  
  67. }
  68.  
  69. double total=0;
  70. for (int i = 0; i <x ; i++) {
  71. if(time[i]!=0){
  72. total=total+time[i];
  73. }
  74. }
  75.  
  76. total=total*10;
  77. int Atlast=(int)total;
  78. System.out.println(Atlast);
  79. }
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement