A - Required Length

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100 点

問題文

高橋君は、ある web サイトに設定するパスワードを、英小文字のみからなる文字列 P にしようと考えています。
一方で、その web サイトのパスワードは長さ L 以上の文字列である必要があります。

P が長さの条件をみたすか、すなわち長さ L 以上の文字列であるか判定してください。

制約

  • P は英小文字のみからなる長さ 1 以上 100 以下の文字列
  • 1 \leq L \leq 100
  • L は整数

入力

入力は以下の形式で標準入力から与えられる。

P
L

出力

P が長さの条件をみたすならば Yes を、そうでないならば No を出力せよ。


入力例 1

chokudai
5

出力例 1

Yes

chokudai の長さは 8 であり、特に 5 以上であるため長さの条件をみたしています。
よって、Yes を出力します。


入力例 2

ac
3

出力例 2

No

ac の長さは 2 であり、特に 3 未満であるため長さの条件をみたしていません。
よって、No を出力します。


入力例 3

atcoder
7

出力例 3

Yes

atcoder の長さは 7 であり、特に 7 以上であるため長さの条件をみたしています。
よって、Yes を出力します。

Score : 100 points

Problem Statement

Takahashi wants to set his password for a certain website to a string P consisting of lowercase English letters.
The password for that website must be a string of length at least L.

Determine whether P satisfies the length condition, that is, whether it is a string of length at least L.

Constraints

  • P is a string consisting of lowercase English letters with length between 1 and 100, inclusive.
  • 1 \leq L \leq 100
  • L is an integer.

Input

The input is given from Standard Input in the following format:

P
L

Output

If P satisfies the length condition, print Yes; otherwise, print No.


Sample Input 1

chokudai
5

Sample Output 1

Yes

The length of chokudai is 8, which is at least 5, so it satisfies the length condition.
Thus, print Yes.


Sample Input 2

ac
3

Sample Output 2

No

The length of ac is 2, which is less than 3, so it does not satisfy the length condition.
Thus, print No.


Sample Input 3

atcoder
7

Sample Output 3

Yes

The length of atcoder is 7, which is at least 7, so it satisfies the length condition.
Thus, print Yes.

B - I'm a teapot

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100 点

問題文

高橋君はティーポットです。
高橋君はティーポットなので、紅茶なら喜んで受け入れますが、それ以外の液体を入れようとすると拒否してしまいます。
高橋君に S という名前の液体を入れることが出来るか判定してください。

英小文字からなる長さ N の文字列 S が与えられます。
S が tea で終わる文字列であるかどうかを判定してください。

制約

  • 1 \leq N \leq 20
  • N は整数
  • S は英小文字からなる長さ N の文字列

入力

入力は以下の形式で標準入力から与えられる。

N
S

出力

S が tea で終わる文字列であれば Yes を、そうでなければ No を出力せよ。


入力例 1

8
greentea

出力例 1

Yes

greentea は tea で終わる文字列です。


入力例 2

6
coffee

出力例 2

No

coffee は tea で終わる文字列ではありません。


入力例 3

3
tea

出力例 3

Yes

入力例 4

1
t

出力例 4

No

Score : 100 points

Problem Statement

Takahashi is a teapot.
Since he is a teapot, he will gladly accept tea, but will refuse any other liquid.
Determine whether you can pour a liquid named S into him.

You are given a string S of length N consisting of lowercase English letters.
Determine whether S is a string that ends with tea.

Constraints

  • 1 \leq N \leq 20
  • N is an integer.
  • S is a string of length N consisting of lowercase English letters.

Input

The input is given from Standard Input in the following format:

N
S

Output

If S is a string that ends with tea, print Yes; otherwise, print No.


Sample Input 1

8
greentea

Sample Output 1

Yes

greentea is a string that ends with tea.


Sample Input 2

6
coffee

Sample Output 2

No

coffee is not a string that ends with tea.


Sample Input 3

3
tea

Sample Output 3

Yes

Sample Input 4

1
t

Sample Output 4

No
C - Nutrients

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 150 点

問題文

健康に気を使っている高橋君は、M 種類の栄養素について、食事によって十分な量を摂取できているか気になりました。

i 番目の栄養素は 1 日あたり A_i 以上摂取することが目標です。

高橋君は今日 N 品の食品を食べ、i 品目の食品からは栄養素 j を X_{i,j} 摂取しました。

M 種類全ての栄養素で目標を達成しているかどうかを判定してください。

制約

  • 1 \leq N \leq 100
  • 1 \leq M \leq 100
  • 0 \leq A_i,X_{i,j} \leq 10^7
  • 入力は全て整数である

入力

入力は以下の形式で標準入力から与えられる。

N M
A_1 \ldots A_M
X_{1,1} \ldots X_{1,M}
\vdots
X_{N,1} \ldots X_{N,M}

出力

M 種類全ての栄養素で目標を達成しているなら Yes、そうでないならば No を出力せよ。


入力例 1

2 3
10 20 30
20 0 10
0 100 100

出力例 1

Yes

栄養素 1 は 1 品目から 20、2 品目から 0 摂取したため、合わせて 20 摂取しており、10 以上摂取するという目標を達成しています。
栄養素 2,3 についても同様に目標を達成しています。


入力例 2

2 4
10 20 30 40
20 0 10 30
0 100 100 0

出力例 2

No

栄養素 4 について目標を達成していません。

Score : 150 points

Problem Statement

Takahashi is health-conscious and concerned about whether he is getting enough of M types of nutrients from his diet.

For the i-th nutrient, his goal is to take at least A_i units per day.

Today, he ate N foods, and from the i-th food, he took X_{i,j} units of nutrient j.

Determine whether he has met the goal for all M types of nutrients.

Constraints

  • 1 \leq N \leq 100
  • 1 \leq M \leq 100
  • 0 \leq A_i, X_{i,j} \leq 10^7
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N M
A_1 \ldots A_M
X_{1,1} \ldots X_{1,M}
\vdots
X_{N,1} \ldots X_{N,M}

Output

Print Yes if the goal is met for all M types of nutrients, and No otherwise.


Sample Input 1

2 3
10 20 30
20 0 10
0 100 100

Sample Output 1

Yes

For nutrient 1, Takahashi took 20 units from the 1-st food and 0 units from the 2-nd food, totaling 20 units, thus meeting the goal of taking at least 10 units.
Similarly, he meets the goal for nutrients 2 and 3.


Sample Input 2

2 4
10 20 30 40
20 0 10 30
0 100 100 0

Sample Output 2

No

The goal is not met for nutrient 4.

D - Permute to Minimize

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200 点

問題文

正整数 X が与えられます。

X を(先頭に 0 を含まない形で)十進表記した際に現れる数字を、先頭に 0 が来ないように 並び替えることで得られる正整数のうち、値が最小のものを求めてください。

制約

  • 1\leq X < 10^5
  • X は整数

入力

入力は以下の形式で標準入力から与えられる。

X

出力

答えを出力せよ。


入力例 1

903

出力例 1

309

X を十進表記した際に現れる数字を先頭に 0 が来ないように並び替えることで得られる正整数は、903, 930, 309, 390 の 4 通りであり、このうち値が最小のものは 309 です。


入力例 2

432

出力例 2

234

入力例 3

100

出力例 3

100

Score : 200 points

Problem Statement

You are given a positive integer X.

Find the minimum value among all positive integers that can be obtained by rearranging the digits appearing in the decimal representation of X (without leading zeros) such that there is no leading zero.

Constraints

  • 1\leq X < 10^5
  • X is an integer.

Input

The input is given from Standard Input in the following format:

X

Output

Output the answer.


Sample Input 1

903

Sample Output 1

309

There are four positive integers that can be obtained by rearranging the digits appearing in the decimal representation of X such that there is no leading zero: 903, 930, 309, 390; the minimum value among them is 309.


Sample Input 2

432

Sample Output 2

234

Sample Input 3

100

Sample Output 3

100
E - One More aab aba baa

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 300 点

問題文

文字列 S の各文字を並べ替えて作ることが可能な文字列を辞書順にすべて列挙したとき、前から K 番目にくる文字列を求めてください。

「各文字を並べ替えて作ることが可能な文字列」とは? 「文字列 A が文字列 B の各文字を並べ替えて作ることが可能な文字列である」とは、任意の文字が文字列 A と文字列 B に同数含まれるということを指します。

制約

  • 1 \le |S| \le 8
  • S は英小文字のみからなる
  • S の各文字を並べ替えてできる文字列は K 種類以上存在する

入力

入力は以下の形式で標準入力から与えられる。

S K

出力

答えを出力せよ。


入力例 1

aab 2

出力例 1

aba

文字列 aab の各文字を並べ替えて作ることが可能な文字列は \{ aab, aba, baa \} の 3 つですが、このうち辞書順で前から 2 番目にくるものは aba です。


入力例 2

baba 4

出力例 2

baab

入力例 3

ydxwacbz 40320

出力例 3

zyxwdcba

Score : 300 points

Problem Statement

Find the K-th lexicographically smallest string among the strings that are permutations of a string S.

What is a permutation of a string?A string A is said to be a permutation of a string B when any character occurs the same number of times in A and B.

Constraints

  • 1 \le |S| \le 8
  • S consists of lowercase English letters.
  • There are at least K distinct strings that are permutations of S.

Input

Input is given from Standard Input in the following format:

S K

Output

Print the answer.


Sample Input 1

aab 2

Sample Output 1

aba

There are three permutations of a string aab: \{ aab, aba, baa \}. The 2-nd lexicographically smallest of them is aba.


Sample Input 2

baba 4

Sample Output 2

baab

Sample Input 3

ydxwacbz 40320

Sample Output 3

zyxwdcba