A - Water Pressure

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100 点

問題文

水圧は水深のみに依存し、水深 x [m] の場所では \dfrac{x}{100} [MPa] になるものとします。

水深 D [m] の場所の水圧は何 [MPa] ですか?

制約

  • 1 \leq D \leq 10000
  • D は整数である。

入力

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

D

出力

答えを出力せよ。想定解答との絶対誤差または相対誤差が 10^{-3} 以下であれば正解として扱われる。


入力例 1

1000

出力例 1

10

水深 1000 [m] の場所の水圧は 10 [MPa] です。10.0 や 9.999999 などを出力しても正解となります。


入力例 2

50

出力例 2

0.5

入力例 3

3141

出力例 3

31.41

Score : 100 points

Problem Statement

Let us assume that water pressure depends only on depth and is \dfrac{x}{100} megapascal at a depth of x meters.

What is the water pressure in megapascals at a depth of D meters?

Constraints

  • 1 \leq D \leq 10000
  • D is an integer.

Input

Input is given from Standard Input in the following format:

D

Output

Print the answer. Your output will be considered correct when its absolute or relative error from our answer is at most 10^{-3}.


Sample Input 1

1000

Sample Output 1

10

The water pressure at a depth of 1000 meters is 10 megapascal. Outputs such as 10.0 and 9.999999 would also be accepted.


Sample Input 2

50

Sample Output 2

0.5

Sample Input 3

3141

Sample Output 3

31.41
B - Penalty Kick

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100 点

問題文

髙橋君はサッカーの試合で N 回ペナルティキックを蹴ります。

髙橋君は i 回目のペナルティキックでは、i が 3 の倍数の場合は失敗しそれ以外の場合は成功します。

髙橋君がペナルティキックを蹴ったときの結果を出力してください。

制約

  • 1 \leq N \leq 100
  • 入力は全て整数である。

入力

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

N

出力

髙橋君のペナルティキックの結果を表す長さ N の文字列を出力せよ。結果を表す文字列の i (1 \leq i \leq N) 文字目は髙橋君が i 回目のペナルティキックで成功した場合は o 、失敗した場合は x とする。


入力例 1

7

出力例 1

ooxooxo

髙橋君は 3 回目と 6 回目のペナルティキックに失敗するので、3 文字目と 6 文字目が x となります。


入力例 2

9

出力例 2

ooxooxoox

Score: 100 points

Problem Statement

Takahashi will have N penalty kicks in a soccer match.

For the i-th penalty kick, he will fail if i is a multiple of 3, and succeed otherwise.

Print the results of his penalty kicks.

Constraints

  • 1 \leq N \leq 100
  • All inputs are integers.

Input

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

N

Output

Print a string of length N representing the results of Takahashi's penalty kicks. The i-th character (1 \leq i \leq N) should be o if Takahashi succeeds in the i-th penalty kick, and x if he fails.


Sample Input 1

7

Sample Output 1

ooxooxo

Takahashi fails the third and sixth penalty kicks, so the third and sixth characters will be x.


Sample Input 2

9

Sample Output 2

ooxooxoox
C - Mex

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200 点

問題文

長さ N の整数からなる数列 A=(A_1,\ldots,A_N) が与えられます。

A_1,\ldots,A_N に含まれない最小の非負整数を求めてください。

制約

  • 1 \leq N \leq 2000
  • 0 \leq A_i \leq 2000
  • 入力は全て整数である

入力

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

N
A_1 \ldots A_N

出力

答えを出力せよ。


入力例 1

8
0 3 2 6 2 1 0 0

出力例 1

4

非負整数は 0,1,2,3,4,\ldots と続きます。
0,1,2,3 は A に含まれ、4 は A に含まれないので、答えは 4 です。


入力例 2

3
2000 2000 2000

出力例 2

0

Score : 200 points

Problem Statement

You are given a sequence of length N consisting of integers: A=(A_1,\ldots,A_N).

Find the smallest non-negative integer not in (A_1,\ldots,A_N).

Constraints

  • 1 \leq N \leq 2000
  • 0 \leq A_i \leq 2000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 \ldots A_N

Output

Print the answer.


Sample Input 1

8
0 3 2 6 2 1 0 0

Sample Output 1

4

The non-negative integers are 0,1,2,3,4,\ldots.
We have 0,1,2,3 in A, but not 4, so the answer is 4.


Sample Input 2

3
2000 2000 2000

Sample Output 2

0
D - Search and Delete

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200 点

問題文

高橋君は長さ N の整数列 A=(A_1,A_2,\ldots,A_N) を持っています。
A は広義単調増加であることが保証されます。

高橋君はこの整数列に対して M 回操作を行います。 i 回目 (1\leq i\leq M) の操作では、次の操作を行います。

数列 A が B_i を要素として持つならば、そのような要素を 1 つ選び、削除する。 そのような要素が存在しないならば何もしない。

A は広義単調増加であるため、操作後の列は要素の選び方によらず一意であり、再び広義単調増加となることに注意せよ。

M 回の操作を行なった後の A を求めてください。

広義単調増加 とは 数列 X=(X_1,X_2,\ldots,X_K) が広義単調増加であるとは、 任意の i (1\leq i\leq K-1) について、 X_i\leq X_{i+1} をみたすことを指します。

制約

  • 1 \leq N \leq 100
  • 1 \leq M \leq 100
  • 1 \leq A_i,B_i \leq 10^9
  • 整数列 A は広義単調増加である。
  • 入力はすべて整数

入力

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

N M
A_1 A_2 \ldots A_N
B_1 B_2 \ldots B_M

出力

操作後の A の各要素を、順に空白区切りで一行に出力せよ。
操作後の A が空ならば、何も出力しないようにせよ。


入力例 1

8 5
1 2 2 3 3 3 5 6
2 2 7 3 2

出力例 1

1 3 3 5 6

最初、A は A=(1,2,2,3,3,3,5,6) です。
操作は次のように行われます。

  • A から 2 を 1 つ削除し、操作後の A は A=(1,2,3,3,3,5,6) となります。
  • A から 2 を 1 つ削除し、操作後の A は A=(1,3,3,3,5,6) となります。
  • A は 7 を要素として持たないため、何も行いません。操作後の A は A=(1,3,3,3,5,6) のままです。
  • A から 3 を 1 つ削除し、操作後の A は A=(1,3,3,5,6) となります。
  • A は 2 を要素として持たないため、何も行いません。操作後の A は A=(1,3,3,5,6) のままです。

よって、すべての操作の後、A=(1,3,3,5,6) であるため、要素をこの順に空白区切りで出力します。


入力例 2

1 2
1
1 1

出力例 2


操作後の A は空となるため、何も出力しません。

Score : 200 points

Problem Statement

Takahashi has an integer sequence A=(A_1,A_2,\ldots,A_N) of length N.
It is guaranteed that A is non-decreasing.

Takahashi performs M operations on this integer sequence. In the i-th operation (1\leq i\leq M), he performs the following operation:

If the sequence A contains B_i as an element, select one such element and delete it. If no such element exists, do nothing.

Note that since A is non-decreasing, the sequence after the operation is uniquely determined regardless of the choice of element, and remains non-decreasing.

Find A after performing M operations.

What is non-decreasing? A sequence X=(X_1,X_2,\ldots,X_K) is non-decreasing if X_i\leq X_{i+1} holds for all i (1\leq i\leq K-1).

Constraints

  • 1 \leq N \leq 100
  • 1 \leq M \leq 100
  • 1 \leq A_i,B_i \leq 10^9
  • The integer sequence A is non-decreasing.
  • All input values are integers.

Input

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

N M
A_1 A_2 \ldots A_N
B_1 B_2 \ldots B_M

Output

Output the elements of A after the operations, in order, separated by spaces on a single line.
If A is empty after the operations, output nothing.


Sample Input 1

8 5
1 2 2 3 3 3 5 6
2 2 7 3 2

Sample Output 1

1 3 3 5 6

Initially, A is A=(1,2,2,3,3,3,5,6).
The operations are performed as follows:

  • Delete one 2 from A, and A becomes A=(1,2,3,3,3,5,6) after the operation.
  • Delete one 2 from A, and A becomes A=(1,3,3,3,5,6) after the operation.
  • Since A does not contain 7 as an element, do nothing. A remains A=(1,3,3,3,5,6) after the operation.
  • Delete one 3 from A, and A becomes A=(1,3,3,5,6) after the operation.
  • Since A does not contain 2 as an element, do nothing. A remains A=(1,3,3,5,6) after the operation.

Therefore, after all operations, A=(1,3,3,5,6), so output the elements in this order separated by spaces.


Sample Input 2

1 2
1
1 1

Sample Output 2


A becomes empty after the operations, so output nothing.

E - Move It

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 250 点

問題文

1 から N の番号がついた N 個の箱と 1 から N の番号がついた N 個の荷物があります。荷物 i (1 \leq i \leq N) は箱 A_i の中にあり、重さは W_i です。

あなたは荷物を一つ選び、他の箱の中に移動させる操作を 0 回以上繰り返し行うことができます。1 回の操作で移動させる荷物の重さが w であるとき、w のコストがかかります。

全ての箱に荷物が 1 つずつ入っている状態にするためにかかるコストの総和の最小値を求めてください。

制約

  • 1 \leq N \leq 10^{5}
  • 1 \leq A_i \leq N (1 \leq i \leq N)
  • 1 \leq W_i \leq 10^{4} (1 \leq i \leq N)
  • 入力はすべて整数

入力

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

N
A_1 A_2 \ldots A_N
W_1 W_2 \ldots W_N

出力

全ての箱に荷物が 1 つずつ入っている状態にするためにかかるコストの総和の最小値を出力せよ。


入力例 1

5
2 2 3 3 5
33 40 2 12 16

出力例 1

35

以下の 2 回の荷物の移動で、すべての箱に荷物が 1 つずつ入っている状態にすることができます。

  • 荷物 1 を箱 2 から箱 1 に移す。このとき、コストは 33 である。
  • 荷物 3 を箱 3 から箱 4 に移す。このとき、コストは 2 である。

この 2 回の荷物の移動は合計 35 のコストかかります。 35 未満のコストですべての箱に荷物が 1 つずつ入っている状態にすることはできないため、 35 を出力します。


入力例 2

12
3 6 7 4 12 4 8 11 11 1 8 11
3925 9785 9752 3587 4013 1117 3937 7045 6437 6208 3391 6309

出力例 2

17254

Score : 250 points

Problem Statement

There are N boxes numbered 1 to N and N items numbered 1 to N. Item i (1 \leq i \leq N) is in box A_i and has a weight of W_i.

You can repeatedly perform the operation of choosing an item and moving it to another box zero or more times. If the weight of the item being moved is w, the cost of the operation is w.

Find the minimum total cost required to make each box contain exactly one item.

Constraints

  • 1 \leq N \leq 10^{5}
  • 1 \leq A_i \leq N (1 \leq i \leq N)
  • 1 \leq W_i \leq 10^{4} (1 \leq i \leq N)
  • All input values are integers.

Input

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

N
A_1 A_2 \ldots A_N
W_1 W_2 \ldots W_N

Output

Print the minimum total cost required to make each box contain exactly one item.


Sample Input 1

5
2 2 3 3 5
33 40 2 12 16

Sample Output 1

35

With the following two moves, you can make each box contain exactly one item:

  • Move item 1 from box 2 to box 1. The cost is 33.
  • Move item 3 from box 3 to box 4. The cost is 2.

The total cost of these two moves is 35. It is impossible to make each box contain exactly one item with a cost less than 35, so print 35.


Sample Input 2

12
3 6 7 4 12 4 8 11 11 1 8 11
3925 9785 9752 3587 4013 1117 3937 7045 6437 6208 3391 6309

Sample Output 2

17254