実行時間制限: 2 sec / メモリ制限: 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
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
英小文字からなる N 個の文字列 W_1,W_2,\dots,W_N が与えられます。
これらのうち一つ以上が and, not, that, the, you のいずれかと一致するなら Yes 、そうでないなら No と出力してください。
制約
- N は 1 以上 100 以下の整数
- 1 \le |W_i| \le 50 ( |W_i| は文字列 W_i の長さ )
- W_i は英小文字からなる
入力
入力は以下の形式で標準入力から与えられる。
N W_1 W_2 \dots W_N
出力
答えを出力せよ。
入力例 1
10 in that case you should print yes and not no
出力例 1
Yes
例えば W_4= you なので、 Yes と出力します。
入力例 2
10 in diesem fall sollten sie no und nicht yes ausgeben
出力例 2
No
文字列 W_i はいずれも、 and, not, that, the, you のいずれとも一致しません。
Score : 100 points
Problem Statement
You are given N strings W_1,W_2,\dots,W_N consisting of lowercase English letters.
If one or more of these strings equal and, not, that, the, or you, then print Yes; otherwise, print No.
Constraints
- N is an integer between 1 and 100, inclusive.
- 1 \le |W_i| \le 50 (|W_i| is the length of W_i.)
- W_i consists of lowercase English letters.
Input
The input is given from Standard Input in the following format:
N W_1 W_2 \dots W_N
Output
Print the answer.
Sample Input 1
10 in that case you should print yes and not no
Sample Output 1
Yes
We have, for instance, W_4= you, so you should print Yes.
Sample Input 2
10 in diesem fall sollten sie no und nicht yes ausgeben
Sample Output 2
No
None of the strings W_i equals any of and, not, that, the, and you.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
長さ N の整数列 A = (A_1, A_2, \dots, A_N), B = (B_1, B_2, \dots, B_N) が与えられます。
A の要素はすべて異なります。B の要素もすべて異なります。
次の 2 つを出力してください。
- A にも B にも含まれ、その位置も一致している整数の個数。言い換えると、A_i = B_i を満たす整数 i の個数。
- A にも B にも含まれるが、その位置は異なる整数の個数。言い換えると、A_i = B_j, i \neq j を満たす整数の組 (i, j) の個数。
制約
- 1 \leq N \leq 1000
- 1 \leq A_i \leq 10^9
- 1 \leq B_i \leq 10^9
- A_1, A_2, \dots, A_N はすべて異なる。
- B_1, B_2, \dots, B_N はすべて異なる。
- 入力はすべて整数である。
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \dots A_N B_1 B_2 \dots B_N
出力
答えを 2 行出力せよ。1 行目には 1. の個数、2 行目には 2. の個数を出力せよ。
入力例 1
4 1 3 5 2 2 3 1 4
出力例 1
1 2
A にも B にも含まれ、その位置も一致している整数は A_2 = B_2 = 3 の 1 個です。
A にも B にも含まれるが、その位置は異なる整数は A_1 = B_3 = 1 と A_4 = B_1 = 2 の 2 個です。
入力例 2
3 1 2 3 4 5 6
出力例 2
0 0
1., 2. ともに条件を満たす整数は存在しません。
入力例 3
7 4 8 1 7 9 5 6 3 5 1 7 8 2 6
出力例 3
3 2
Score : 200 points
Problem Statement
You are given integer sequences, each of length N: A = (A_1, A_2, \dots, A_N) and B = (B_1, B_2, \dots, B_N).
All elements of A are different. All elements of B are different, too.
Print the following two values.
- The number of integers contained in both A and B, appearing at the same position in the two sequences. In other words, the number of integers i such that A_i = B_i.
- The number of integers contained in both A and B, appearing at different positions in the two sequences. In other words, the number of pairs of integers (i, j) such that A_i = B_j and i \neq j.
Constraints
- 1 \leq N \leq 1000
- 1 \leq A_i \leq 10^9
- 1 \leq B_i \leq 10^9
- A_1, A_2, \dots, A_N are all different.
- B_1, B_2, \dots, B_N are all different.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N A_1 A_2 \dots A_N B_1 B_2 \dots B_N
Output
Print the answers in two lines: the answer to1. in the first line, and the answer to2. in the second line.
Sample Input 1
4 1 3 5 2 2 3 1 4
Sample Output 1
1 2
There is one integer contained in both A and B, appearing at the same position in the two sequences: A_2 = B_2 = 3.
There are two integers contained in both A and B, appearing at different positions in the two sequences: A_1 = B_3 = 1 and A_4 = B_1 = 2.
Sample Input 2
3 1 2 3 4 5 6
Sample Output 2
0 0
In both 1. and 2., no integer satisfies the condition.
Sample Input 3
7 4 8 1 7 9 5 6 3 5 1 7 8 2 6
Sample Output 3
3 2
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
1 から N までの番号がついた N 人の選手がサッカーの試合をします。
選手が反則を犯したとき、その選手には イエローカード と レッドカード のどちらかが提示されます。
以下の条件のうち一方を満たした選手は 退場処分 と呼ばれるペナルティを受けます。
- イエローカードを累計 2 回提示される。
- レッドカードを提示される。
なお、退場処分を受けた選手にそれ以降カードが提示されることはありません。
あなたはこの試合を観戦します。はじめ、すべての選手はカードを 1 回も提示されていません。
Q 個のイベントが発生するので、イベントで聞かれる質問に正しく答えてください。
イベントは 3 種類あり、c x (c は 1, 2, 3 のいずれか) という形式で入力から与えられます。イベントの説明は次の通りです。
1 x: 選手 x にイエローカードが提示される。2 x: 選手 x にレッドカードが提示される。3 x: あなたは選手 x が退場処分を受けたかを質問される。選手 x が退場処分を受けていればYesと、そうでなければNoと答える。
制約
- 1 \leq N \leq 100
- 1 \leq Q \leq 100
- 全てのイベントにおいて 1 \leq x \leq N
- 3 種類目のイベントは少なくとも 1 個以上存在する
- すでに退場処分を受けた選手にカードが提示されることはない
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。ただし、\text{event}_i は i 番目に発生するイベントを意味する。
N Q
\text{event}_1
\text{event}_2
\vdots
\text{event}_Q
イベントは次の 3 つのいずれかの形式で入力される。
1 x
2 x
3 x
出力
入力で与えられる 3 種類目のイベントの個数を X として、X 行出力せよ。
i 行目には、3 種類目のイベントのうち i 番目のもので聞かれる質問について、選手 x が退場処分を受けていれば Yes を、そうでなければ No を出力せよ。
入力例 1
3 9 3 1 3 2 1 2 2 1 3 1 3 2 1 2 3 2 3 3
出力例 1
No No Yes No Yes No
イベントを時系列順にすべて説明すると次の通りです。
1 番目のイベントでは、あなたは選手 1 が退場処分を受けたかを質問されます。選手 1 は退場処分を受けていないので No を出力します。
2 番目のイベントでは、あなたは選手 2 が退場処分を受けたかを質問されます。選手 2 は退場処分を受けていないので No を出力します。
3 番目のイベントでは、選手 2 にイエローカードが提示されます。
4 番目のイベントでは、選手 1 にレッドカードが提示されます。選手 1 は退場処分を受けます。
5 番目のイベントでは、あなたは選手 1 が退場処分を受けたかを質問されます。選手 1 は退場処分を受けたので Yes を出力します。
6 番目のイベントでは、あなたは選手 2 が退場処分を受けたかを質問されます。選手 2 は退場処分を受けていないので No を出力します。
7 番目のイベントでは、選手 2 にイエローカードが提示されます。選手 2 は退場処分を受けます。
8 番目のイベントでは、あなたは選手 2 が退場処分を受けたかを質問されます。選手 2 は退場処分を受けたので Yes を出力します。
9 番目のイベントでは、あなたは選手 3 が退場処分を受けたかを質問されます。選手 3 は退場処分を受けていないので No を出力します。
Score : 200 points
Problem Statement
N players numbered 1 to N will play a soccer game.
When a player commits an offense, that player will receive a yellow card or a red card.
A player who satisfies one of the following conditions will be removed from the game.
- Accumulates two yellow cards.
- Receives a red card.
Once a player is removed, that player will no longer receive any cards.
You will watch this game. Initially, the players have not received any cards.
There will be Q events. Correctly answer the questions asked in the events.
There are three kinds of events, which are given in the format c x from the input, where c is 1, 2, or 3. The events are as follows.
1 x: Player x receives a yellow card.2 x: Player x receives a red card.3 x: You are asked whether player x has been removed from the game. AnswerYesorNo.
Constraints
- 1 \leq N \leq 100
- 1 \leq Q \leq 100
- 1 \leq x \leq N in all events.
- There is at least one event of the third kind.
- A player who has been removed will no longer receive any cards.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format, where \text{event}_i denotes the i-th event.
N Q
\text{event}_1
\text{event}_2
\vdots
\text{event}_Q
Each event is in one of the following formats:
1 x
2 x
3 x
Output
Print X lines, where X is the number of events of the third kind in the input.
The i-th line should contain Yes if, for the i-th event of the third kind, player x has been removed from the game, and No otherwise.
Sample Input 1
3 9 3 1 3 2 1 2 2 1 3 1 3 2 1 2 3 2 3 3
Sample Output 1
No No Yes No Yes No
Here are all the events in chronological order.
In the 1-st event, you are asked whether player 1 has been removed from the game. Player 1 has not been removed, so you should print No.
In the 2-nd event, you are asked whether player 2 has been removed from the game. Player 2 has not been removed, so you should print No.
In the 3-rd event, player 2 receives a yellow card.
In the 4-th event, player 1 receives a red card and is removed from the game.
In the 5-th event, you are asked whether player 1 has been removed from the game. Player 1 has been removed, so you should print Yes.
In the 6-th event, you are asked whether player 2 has been removed from the game. Player 2 has not been removed, so you should print No.
In the 7-th event, player 2 receives a yellow card and is removed from the game.
In the 8-th event, you are asked whether player 2 has been removed from the game. Player 2 has been removed, so you should print Yes.
In the 9-th event, you are asked whether player 3 has been removed from the game. Player 3 has not been removed, so you should print No.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 300 点
問題文
N 曲からなるプレイリストがあり、曲には 1, \dots, N の番号が付けられています。
曲 i の長さは A_i 秒です。
プレイリストを再生すると、曲 1、曲 2、\ldots、曲 N の順に流れます。曲 N が流れ終わると、再び曲 1 から順に流れていきます。ある曲の途中で次の曲が流れることはなく、曲が流れ終わると、その瞬間に次の曲が流れ始めます。
プレイリストを再生してから T 秒後に流れているのはどの曲ですか?また、その曲が流れ始めてから何秒の時点ですか?
ただし、T 秒後ちょうどに曲が切り替わるような入力は与えられません。
制約
- 1 \leq N \leq 10^5
- 1 \leq T \leq 10^{18}
- 1 \leq A_i \leq 10^9
- プレイリストを再生して T 秒後ちょうどに曲が切り替わることはない
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N T A_1 \ldots A_N
出力
プレイリストを再生してから T 秒後に流れている曲の番号と、その曲が流れ始めてから何秒たったかを表す整数を空白区切りで出力せよ。
入力例 1
3 600 180 240 120
出力例 1
1 60
プレイリストを再生してからの様子は次のようになります。
- 0 秒後から 180 秒後まで曲 1 が流れる。
- 180 秒後から 420 秒後まで曲 2 が流れる。
- 420 秒後から 540 秒後まで曲 3 が流れる。
- 540 秒後から 720 秒後まで曲 1 が流れる。
- 720 秒後から 960 秒後まで曲 2 が流れる。
- \qquad\vdots
600 秒後の時点で流れているのは曲 1 であり、流れ始めて 60 秒の時点です。
入力例 2
3 281 94 94 94
出力例 2
3 93
入力例 3
10 5678912340 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
出力例 3
6 678912340
Score : 300 points
Problem Statement
We have a playlist with N songs numbered 1, \dots, N.
Song i lasts A_i seconds.
When the playlist is played, song 1, song 2, \ldots, and song N play in this order. When song N ends, the playlist repeats itself, starting from song 1 again. While a song is playing, the next song does not play; when a song ends, the next song starts immediately.
At exactly T seconds after the playlist starts playing, which song is playing? Also, how many seconds have passed since the start of that song?
There is no input where the playlist changes songs at exactly T seconds after it starts playing.
Constraints
- 1 \leq N \leq 10^5
- 1 \leq T \leq 10^{18}
- 1 \leq A_i \leq 10^9
- The playlist does not change songs at exactly T seconds after it starts playing.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
N T A_1 \ldots A_N
Output
Print an integer representing the song that is playing at exactly T seconds after the playlist starts playing, and an integer representing the number of seconds that have passed since the start of that song, separated by a space.
Sample Input 1
3 600 180 240 120
Sample Output 1
1 60
When the playlist is played, the following happens. (Assume that it starts playing at time 0.)
- From time 0 to time 180, song 1 plays.
- From time 180 to time 420, song 2 plays.
- From time 420 to time 540, song 3 plays.
- From time 540 to time 720, song 1 plays.
- From time 720 to time 960, song 2 plays.
- \qquad\vdots
At time 600, song 1 is playing, and 60 seconds have passed since the start of that song.
Sample Input 2
3 281 94 94 94
Sample Output 2
3 93
Sample Input 3
10 5678912340 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
Sample Output 3
6 678912340