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.

Examples

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'}.

对于这个题,我们的做法是把26个字母任取两个进行枚举,看在字符串中那些最多

代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm> using namespace std;
string str[105];
int main()
{
int n;
cin>>n;
for(int t=0;t<n;t++)
{
cin>>str[t];
}
int sum;
int maxn=0;
for(int i='a';i<='z';i++)
{
for(int j=i;j<='z';j++)
{ sum=0;
for(int k=0;k<n;k++)
{
int len=str[k].length();
int m;
for( m=0;m<len;m++)
{
if(str[k][m]!=i&&str[k][m]!=j)
{
break;
}
}
if(m==len)
{
sum+=len;
}
}
maxn=max(maxn,sum);
}
} cout<<maxn<<endl;
return 0;
}

CodeForces - 593A -2Char(思维+暴力枚举)的更多相关文章

  1. CodeForces - 1244D (思维+暴力)

    题意 https://vjudge.net/problem/CodeForces-1244D 有一棵树,有3种颜色,第i个节点染成第j种颜色的代价是c(i,j),现在要你求出一种染色方案,使得总代价最 ...

  2. Codeforces 626E Simple Skewness(暴力枚举+二分)

    E. Simple Skewness time limit per test:3 seconds memory limit per test:256 megabytes input:standard ...

  3. codeforces Restore Cube(暴力枚举)

    /* 题意:给出立方体的每个顶点的坐标(是由源坐标三个数某几个数被交换之后得到的!), 问是否可以还原出一个立方体的坐标,注意这一句话: The numbers in the i-th output ...

  4. codeforces 700C Break Up 暴力枚举边+边双缩点(有重边)

    题意:n个点,m条无向边,每个边有权值,给你 s 和 t,问你至多删除两条边,让s,t不连通,问方案的权值和最小为多少,并且输出删的边 分析:n<=1000,m是30000  s,t有4种情况( ...

  5. Diverse Garland CodeForces - 1108D (贪心+暴力枚举)

    You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ...

  6. CodeForces 496D Tennis Game (暴力枚举)

    题意:进行若干场比赛,每次比赛两人对决,赢的人得到1分,输的人不得分,先得到t分的人获胜,开始下场比赛,某个人率先赢下s场比赛时, 游戏结束.现在给出n次对决的记录,问可能的s和t有多少种,并按s递增 ...

  7. CodeForces 593A 2Char

    暴力. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> u ...

  8. Codeforces 327A-Flipping Game(暴力枚举)

    A. Flipping Game time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  9. CodeForces - 1230C(思维/暴力)

    题意 https://vjudge.net/problem/CodeForces-1230C 给了你总共有21张多米诺骨牌,每张牌有两个面,然后给你一个无向图,保证没有环和一个顶点多条边的情况存在.现 ...

随机推荐

  1. 《Android安全机制解析与应用实践》笔记 第2章

    Android扩展了Linux内核安全模型的用户与权限机制,将多用户操作系统的用户隔离机制巧妙地移植为应用程序隔离.在linux中,一个用户标识(UID)识别一个给定用户:在Android上,一个UI ...

  2. Android广播接收者

    其实,在什么是广播的第一句就已经说明了广播有什么用了.对了,笼统一点讲就是用来传输数据的.具体一点说就是:1. 实现了不同的程序之间的数据传输与共享,因为只要是和发送广播的action相同的接受者都能 ...

  3. Codeforces 1136F Cooperative Game (神仙题)

    这种题就是难者不会,会者不难. 博客讲的很详细了 代码: #include <bits/stdc++.h> using namespace std; string s; int read( ...

  4. HDOJ 1097 A hard puzzle

    Problem Description lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how ...

  5. Python 使用其他邮件服务商的 SMTP 访问(QQ、网易、163、Google等)发送邮件

    163邮箱SMTP授权 使用Python SMTP发送邮件 # -*- coding:utf-8 -*- from __future__ import print_function __author_ ...

  6. Luogu 2737 [USACO4.1]麦香牛块Beef McNuggets

    NOIP2017 D1T1 的结论,两个数$a, b$所不能表示出的最大的数为$a * b - a - b$. 听了好几遍证明我还是不会 注意到本题中给出的数都非常小,所以最大不能表示出的数$\leq ...

  7. libtool的工作原理

    libtool 是一个通用库支持脚本,将使用动态库的复杂性隐藏在统一.可移植的接口中:使用libtool的标准方法,可以在不同平台上创建并调用动态库.可以认为libtool是gcc的一个抽象,其包装了 ...

  8. 【Android开源】CircleImageView自定义圆形控件的使用

    github地址:https://github.com/hdodenhof/CircleImageView package de.hdodenhof.circleimageview; import e ...

  9. url-pattern 的设置与匹配

  10. 输入框获取焦点后placeholder文字消失、修改placeholder的样式

    输入框获取焦点后placeholder文字消失: <input placeholder='' onfocus="this.placeholder=''" onblur=&qu ...