Codeforces Round #329(Div.2) (2/5)

maksyuki 发表于 比赛 分类,标签:
0

 A 2Char

Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters. Andrew decided to send an article to the magazine, but as he hasn't written any article, he just decided to take a random one from magazine 26Char. However, before sending it to the magazine 2Char, he needs to adapt the text to the format of the journal. To do so, he removes some words from the chosen article, in such a way that the remaining text can be written using no more than two distinct letters.

Since the payment depends from the number of non-space characters in the article, Andrew wants to keep the words with the maximum total length.

Input

The first line of the input contains number n (1 ≤ n ≤ 100) — the number of words in the article chosen by Andrew. Following are n lines, each of them contains one word. All the words consist only of small English letters and their total length doesn't exceed 1000. The words are not guaranteed to be distinct, in this case you are allowed to use a word in the article as many times as it appears in the input.

Output

Print a single integer — the maximum possible total length of words in Andrew's article.

Sample test(s)

input

4
abb
cacc
aaa
bbb

output

9

input

5
a
a
bcbcb
cdecdecdecdecdecde
aaaa

output

6

Note

In the first sample the optimal way to choose words is {'abb', 'aaa', 'bbb'}.

In the second sample the word 'cdecdecdecdecdecde' consists of three distinct letters, and thus cannot be used in the article. The optimal answer is {'a', 'a', 'aaaa'}.

 

题目类型:暴力枚举

算法分析:先预处理出每个字符串的字符种数和个数,然后双重循环枚举两个字符,并更新最大值

 

 B Anton and Lines

The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = ki·x + bi. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x1 < x2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that:

  • y' = ki * x' + bi, that is, point (x', y')belongs to the line number i;
  • y' = kj * x' + bj, that is, point (x', y')belongs to the line number j;
  • x1 < x' < x2, that is, point (x', y')lies inside the strip bounded by x1 < x2.

You can't leave Anton in trouble, can you? Write a program that solves the given task.

Input

The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x1 and x2 ( - 1 000 000 ≤ x1 < x2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines.

The following n lines contain integers kibi ( - 1 000 000 ≤ ki, bi ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either ki ≠ kj, or bi ≠ bj.

Output

Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes).

Sample test(s)

input

4
1 2
1 2
1 0
0 1
0 2

output

NO

input

2
1 3
1 0
-1 3

output

YES

input

2
1 3
1 0
0 2

output

YES

input

2
1 3
1 0
0 3

output

NO

Note

In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it.

 

题目类型:简单几何

算法分析:计算出所有的直线在x1+EPS和x2-EPS处的值y1和y2,然后分别对两个位置处的函数值排序,若两端的y值从小到大都属于同一个直线的话,则说明没有直线相交,否则有直线相交