Passwords
time limit per test 2 seconds memory limit per test 256 megabytes
input standard input output standard output

Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can’t remember which one exactly he specified during Codehorses registration.

Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitrary order. Just when Vanya will have entered the correct password, he is immediately authorized on the site. Vanya will not enter any password twice.
Entering any passwords takes one second for Vanya. But if Vanya will enter wrong password k times, then he is able to make the next try only 5 seconds after that. Vanya makes each try immediately, that is, at each moment when Vanya is able to enter password, he is doing that.
Determine how many seconds will Vanya need to enter Codehorses in the best case for him (if he spends minimum possible number of second) and in the worst case (if he spends maximum possible amount of seconds).

传送门:CF721B

Input

The first line of the input contains two integers n and k (1≤n,k≤100) — the number of Vanya's passwords and the number of failed tries, after which the access to the site is blocked for 5 seconds. The next n lines contains passwords, one per line — pairwise distinct non-empty strings consisting of latin letters and digits. Each password length does not exceed 100 characters. The last line of the input contains the Vanya's Codehorses password. It is guaranteed that the Vanya's Codehorses password is equal to some of his n passwords.

Output

Print two integers — time (in seconds), Vanya needs to be authorized to Codehorses in the best case for him and in the worst case respectively.

Sample Input

1
2
3
4
5
6
7
5 2
cba
abc
bb1
abC
ABC
abc

Sample Output

1
1 15

题解

水题 下面展示了两种计数的方式 一种模拟 一种直接计算(其实是我一开始脑抽了0.0Set也是。。抽了好几下就没改过来。。)
## AC code:(不包含输入类)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.io.*;  
import java.util.*;
public class Main {
static class MyString implements Comparable{
MyString(String s){
string=s;
}
private String string;
@Override
public int compareTo(Object arg0) {
MyString s=(MyString)arg0;
if(this.string.length()<s.string.length()) return -1;
else if(this.string.length()>s.string.length()) return 1;
else{
if(this.string.compareTo(s.string)<0) return -1;
else return 1;
}
}
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
int n=sc.nextInt();
int k=sc.nextInt();
int min=0;
int max=0;
TreeSet<MyString>set=new TreeSet<MyString>();
for(int i=1;i<=n;i++){
set.add(new MyString(sc.next()));
}
String answer=sc.next();
Iterator<MyString> i=set.iterator();
int js=0;
boolean flag1=false;
//boolean flag2=false;
int gs=0;
if(set.first().string.length()==answer.length()){
min=1;
flag1=true;
}
while(i.hasNext()){
MyString s=i.next();
if(s.string.length()<=answer.length()){
gs++;
}
if(flag1==false){
if(s.string.length()==answer.length()){
min++;
flag1=true;
}
else{
min++;
js++;
if(js==k){
min=min+5;
js=0;
}
}
}
}
gs=gs-1;
max=gs+gs/k*5+1;
System.out.print(min+" "+max);
}

}

}