Educational Codeforces Round 26 A C 之Python

A. Text Volume

You are given a text of single-space separated words, consisting of small and capital Latin letters.

Volume of the word is number of capital letters in the word. Volume of the text is maximum volume of all words in the text.

Calculate the volume of the given text.

Input

The first line contains one integer number n (1 ≤ n ≤ 200) — length of the text.

The second line contains text of single-space separated words s1, s2, ..., si, consisting only of small and capital Latin letters.

Output

Print one integer number — volume of text.

Examples
Input
7
NonZERO
Output
5
Input
24
this is zero answer text
Output
0
Input
24
Harbour Space University
Output
1
Note

In the first example there is only one word, there are 5 capital letters in it.

In the second example all of the words contain 0 capital letters.

 

 

判断每个字符串中大写字母出现的次数的最大值

#python3
n, a = input(), input().split()
k = 0
for i in a:
    ans = 0
    for c in i:
        if c.isupper():
            ans += 1
    k = max(k, ans)
print(k)

 

C. Two Seals

One very important person has a piece of paper in the form of a rectangle a × b.

Also, he has n seals. Each seal leaves an impression on the paper in the form of a rectangle of the size xi × yi. Each impression must be parallel to the sides of the piece of paper (but seal can be rotated by 90 degrees).

A very important person wants to choose two different seals and put them two impressions. Each of the selected seals puts exactly one impression. Impressions should not overlap (but they can touch sides), and the total area occupied by them should be the largest possible. What is the largest area that can be occupied by two seals?

Input

The first line contains three integer numbers n, a and b (1 ≤ n, a, b ≤ 100).

Each of the next n lines contain two numbers xi, yi (1 ≤ xi, yi ≤ 100).

Output

Print the largest total area that can be occupied by two seals. If you can not select two seals, print 0.

Examples
Input
2 2 2
1 2
2 1
Output
4
Input
4 10 9
2 3
1 1
5 10
9 11
Output
56
Input
3 10 10
6 6
7 7
20 5
Output
0
Note

In the first example you can rotate the second seal by 90 degrees. Then put impression of it right under the impression of the first seal. This will occupy all the piece of paper.

In the second example you can't choose the last seal because it doesn't fit. By choosing the first and the third seals you occupy the largest area.

In the third example there is no such pair of seals that they both can fit on a piece of paper.

 

在n×m的矩形中可以放如两个矩形求使得面积最大的是多少

#python3
k, n, m = map(int,input().split())
x, y = [],[]
for i in range(k):
    q, p = map(int, input().split())
    x.append(min(q, p))
    y.append(max(q, p))
MAX = 0
for i in range(k):
    for j in range(i+1,k):
        ok = False
        if x[i] + x[j] <= n and y[i] <= m and y[j] <= m:
            ok = True
        elif x[i] + y[j] <= n and y[i] <= m and x[j] <= m:
            ok = True
        elif y[i] + y[j] <= m and x[i] <= n and x[j] <= n:
            ok = True
        elif y[i] + x[j] <= m and x[i] <= n and y[j] <= n:
            ok = True
        elif y[i] + y[j] <= n and x[i] <= m and x[j] <= m:
            ok = True
        elif y[i] + x[j] <= n and x[i] <= m and y[j] <= m:
            ok = True
        elif x[i] + x[j] <= m and y[i] <= n and y[j] <= n:
            ok = True
        elif x[i] + y[j] <= m and y[i] <= n and x[j] <= n:
            ok = True
        if ok:
            MAX = max(MAX, x[i]*y[i] + x[j]*y[j])
print(MAX)

 

转载于:https://www.cnblogs.com/xingkongyihao/p/7285135.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值