Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
長さ N の整数列 A と整数 K,X が与えられます。
整数列 A の K 要素目の直後に整数 X を 1 つ挿入した整数列 B を出力してください。
制約
- 入力は全て整数
- 1 \le K \le N \le 100
- 1 \le A_i,X \le 100
入力
入力は以下の形式で標準入力から与えられる。
N K X A_1 A_2 \dots A_N
出力
整数列 A の K 要素目の直後に整数 X を 1 つ挿入した整数列 B を、以下の形式で出力せよ。
B_1 B_2 \dots B_{N+1}
入力例 1
4 3 7 2 3 5 11
出力例 1
2 3 5 7 11
K=3, X=7, A=(2,3,5,11) のとき、 B=(2,3,5,7,11) です。
入力例 2
1 1 100 100
出力例 2
100 100
入力例 3
8 8 3 9 9 8 2 4 4 3 5
出力例 3
9 9 8 2 4 4 3 5 3
Score : 100 points
Problem Statement
You are given an integer sequence A of length N and integers K and X.
Print the integer sequence B obtained by inserting the integer X immediately after the K-th element of the sequence A.
Constraints
- All input values are integers.
- 1 \le K \le N \le 100
- 1 \le A_i, X \le 100
Input
The input is given from Standard Input in the following format:
N K X A_1 A_2 \dots A_N
Output
Print the integer sequence B obtained by inserting the integer X immediately after the K-th element of the sequence A, in the following format:
B_1 B_2 \dots B_{N+1}
Sample Input 1
4 3 7 2 3 5 11
Sample Output 1
2 3 5 7 11
For K=3, X=7, and A=(2,3,5,11), we get B=(2,3,5,7,11).
Sample Input 2
1 1 100 100
Sample Output 2
100 100
Sample Input 3
8 8 3 9 9 8 2 4 4 3 5
Sample Output 3
9 9 8 2 4 4 3 5 3
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
長さ N の正整数列 A=(A_1,A_2,\dots,A_N) が与えられます。
A の奇数番目の要素の総和を求めてください。すなわち、N 以下の最大の奇数を m としたとき A_1+A_3+A_5+\ldots+A_m を求めてください。
制約
- 1\leq N\leq 100
- 1\leq A_i\leq 100
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \ldots A_N
出力
答えを出力せよ。
入力例 1
7 3 1 4 1 5 9 2
出力例 1
14
A の奇数番目の要素の総和は A_1+A_3+A_5+A_7=3+4+5+2=14 です。
入力例 2
1 100
出力例 2
100
入力例 3
14 100 10 1 10 100 10 1 10 100 10 1 10 100 10
出力例 3
403
Score : 100 points
Problem Statement
You are given a sequence of positive integers of length N: A=(A_1,A_2,\dots,A_N).
Find the sum of the odd-indexed elements of A. That is, find A_1 + A_3 + A_5 + \dots + A_m, where m is the largest odd number not exceeding N.
Constraints
- 1 \le N \le 100
- 1 \le A_i \le 100
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 A_2 \dots A_N
Output
Print the answer.
Sample Input 1
7 3 1 4 1 5 9 2
Sample Output 1
14
The sum of the odd-indexed elements of A is A_1+A_3+A_5+A_7=3+4+5+2=14.
Sample Input 2
1 100
Sample Output 2
100
Sample Input 3
14 100 10 1 10 100 10 1 10 100 10 1 10 100 10
Sample Output 3
403
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
次の図に示す、各マスが黒または白に塗られた縦 15 行 \times 横 15 列のグリッドにおいて、 上から R 行目、左から C 列目のマスが何色かを出力して下さい。
制約
- 1 \leq R, C \leq 15
- R, C は整数
入力
入力は以下の形式で標準入力から与えられる。
R C
出力
図のグリッドにおいて上から R 行目、左から C 列目のマスが黒色の場合は black
と、白色の場合は white
と出力せよ。
ジャッジは英小文字と英大文字を厳密に区別することに注意せよ。
入力例 1
3 5
出力例 1
black
図のグリッドにおいて上から 3 行目、左から 5 列目のマスは黒色です。
よって、black
と出力します。
入力例 2
4 5
出力例 2
white
図のグリッドにおいて上から 4 行目、左から 5 列目のマスは白色です。
よって、white
と出力します。
Score : 200 points
Problem Statement
Print the color of the cell at the R-th row from the top and C-th column from the left in the following grid with 15 vertical rows and 15 horizontal columns.
Constraints
- 1 \leq R, C \leq 15
- R and C are integers.
Input
Input is given from Standard Input in the following format:
R C
Output
In the grid above, if the color of the cell at the R-th row from the top and C-th column from the left is black, then print black
; if the cell is white, then print white
. Note that the judge is case-sensitive.
Sample Input 1
3 5
Sample Output 1
black
In the grid above, the cell at the 3-rd row from the top and 5-th column from the left is black. Thus, black
should be printed.
Sample Input 2
4 5
Sample Output 2
white
In the grid above, the cell at the 4-th row from the top and 5-th column from the left is white. Thus, white
should be printed.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
x 軸の正の向きが右、y 軸の正の向きが上であるような xy 座標平面において、点 (a,b) を原点を中心として反時計回りに d 度回転させた点を求めてください。
制約
- -1000 \leq a,b \leq 1000
- 1 \leq d \leq 360
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
a b d
出力
求めるべき点を (a',b') とするとき、 a' と b' をこの順に空白区切りで出力せよ。
なお、各出力について、解との絶対誤差または相対誤差が 10^{−6} 以下であれば正解として扱われる。
入力例 1
2 2 180
出力例 1
-2 -2
(2,2) を原点を中心として反時計回りに 180 度回転させた点は、(2,2) を原点について対称な位置に移動させた点であり、(-2,-2) となります。
入力例 2
5 0 120
出力例 2
-2.49999999999999911182 4.33012701892219364908
(5,0) を原点を中心として反時計回りに 120 度回転させた点は (-\frac {5}{2} , \frac {5\sqrt{3}}{2}) です。
この例での出力はこれらの値と厳密には一致しませんが、誤差が十分に小さいため正解として扱われます。
入力例 3
0 0 11
出力例 3
0.00000000000000000000 0.00000000000000000000
(a,b) が原点(回転の中心)なので回転させても座標が変わりません。
入力例 4
15 5 360
出力例 4
15.00000000000000177636 4.99999999999999555911
360 度回転させたので座標が変わりません。
入力例 5
-505 191 278
出力例 5
118.85878514480690171240 526.66743699786547949770
Score : 200 points
Problem Statement
In an xy-coordinate plane whose x-axis is oriented to the right and whose y-axis is oriented upwards, rotate a point (a, b) around the origin d degrees counterclockwise and find the new coordinates of the point.
Constraints
- -1000 \leq a,b \leq 1000
- 1 \leq d \leq 360
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
a b d
Output
Let the new coordinates of the point be (a', b'). Print a' and b' in this order, with a space in between.
Your output will be considered correct when, for each value printed, the absolute or relative error from the answer is at most 10^{-6}.
Sample Input 1
2 2 180
Sample Output 1
-2 -2
When (2, 2) is rotated around the origin 180 degrees counterclockwise, it becomes the symmetric point of (2, 2) with respect to the origin, which is (-2, -2).
Sample Input 2
5 0 120
Sample Output 2
-2.49999999999999911182 4.33012701892219364908
When (5, 0) is rotated around the origin 120 degrees counterclockwise, it becomes (-\frac {5}{2} , \frac {5\sqrt{3}}{2}).
This sample output does not precisely match these values, but the errors are small enough to be considered correct.
Sample Input 3
0 0 11
Sample Output 3
0.00000000000000000000 0.00000000000000000000
Since (a, b) is the origin (the center of rotation), a rotation does not change its coordinates.
Sample Input 4
15 5 360
Sample Output 4
15.00000000000000177636 4.99999999999999555911
A 360-degree rotation does not change the coordinates of a point.
Sample Input 5
-505 191 278
Sample Output 5
118.85878514480690171240 526.66743699786547949770
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 350 点
問題文
高橋君は医者のすぬけ君から N 種類の薬を処方されました。i 種類目の薬は(処方された日を含めて) a_i 日間、毎日 b_i 錠ずつ飲む必要があります。また、高橋君はこれ以外の薬を飲む必要がありません。
薬を処方された日を 1 日目とします。1 日目以降で、初めて高橋君がその日に飲む必要がある薬が K 錠以下になるのは何日目かを求めてください。
制約
- 1 \leq N \leq 3 \times 10^5
- 0 \leq K \leq 10^9
- 1 \leq a_i,b_i \leq 10^9
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N K a_1 b_1 \vdots a_N b_N
出力
1 日目以降で、初めて高橋君がその日に飲む必要がある薬が K 錠以下になるのが X 日目の時、 X を出力せよ。
入力例 1
4 8 6 3 2 5 1 9 4 2
出力例 1
3
1 日目には、高橋君は 1,2,3,4 種類目の薬をそれぞれ 3,5,9,2 錠飲む必要があります。よってこの日は 19 錠飲む必要があり、K(=8) 錠以下ではありません。
2 日目には、高橋君は 1,2,4 種類目の薬をそれぞれ 3,5,2 錠飲む必要があります。よってこの日は 10 錠飲む必要があり、K(=8) 錠以下ではありません。
3 日目には、高橋君は 1,4 種類目の薬をそれぞれ 3,2 錠飲む必要があります。よってこの日は 5 錠飲む必要があり、初めて K(=8) 錠以下になります。
以上より、3 が答えです。
入力例 2
4 100 6 3 2 5 1 9 4 2
出力例 2
1
入力例 3
15 158260522 877914575 2436426 24979445 61648772 623690081 33933447 476190629 62703497 211047202 71407775 628894325 31963982 822804784 50968417 430302156 82631932 161735902 80895728 923078537 7723857 189330739 10286918 802329211 4539679 303238506 17063340 492686568 73361868 125660016 50287940
出力例 3
492686569
Score : 350 points
Problem Statement
Snuke the doctor prescribed N kinds of medicine for Takahashi. For the next a_i days (including the day of the prescription), he has to take b_i pills of the i-th medicine. He does not have to take any other medicine.
Let the day of the prescription be day 1. On or after day 1, when is the first day on which he has to take K pills or less?
Constraints
- 1 \leq N \leq 3 \times 10^5
- 0 \leq K \leq 10^9
- 1 \leq a_i,b_i \leq 10^9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N K a_1 b_1 \vdots a_N b_N
Output
If Takahashi has to take K pills or less on day X for the first time on or after day 1, print X.
Sample Input 1
4 8 6 3 2 5 1 9 4 2
Sample Output 1
3
On day 1, he has to take 3,5,9, and 2 pills of the 1-st, 2-nd, 3-rd, and 4-th medicine, respectively. In total, he has to take 19 pills on this day, which is not K(=8) pills or less.
On day 2, he has to take 3,5, and 2 pills of the 1-st, 2-nd, and 4-th medicine, respectively. In total, he has to take 10 pills on this day, which is not K(=8) pills or less.
On day 3, he has to take 3 and 2 pills of the 1-st and 4-th medicine, respectively. In total, he has to take 5 pills on this day, which is K(=8) pills or less for the first time.
Thus, the answer is 3.
Sample Input 2
4 100 6 3 2 5 1 9 4 2
Sample Output 2
1
Sample Input 3
15 158260522 877914575 2436426 24979445 61648772 623690081 33933447 476190629 62703497 211047202 71407775 628894325 31963982 822804784 50968417 430302156 82631932 161735902 80895728 923078537 7723857 189330739 10286918 802329211 4539679 303238506 17063340 492686568 73361868 125660016 50287940
Sample Output 3
492686569