Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
長さ 3 の文字列 S が与えられます。
S に 1 度だけ含まれる文字を 1 つ出力してください。
但し、そのような文字が存在しない場合は代わりに -1 と出力してください。
制約
- S は英小文字のみからなる 3 文字の文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを出力せよ。正解が複数ある場合、どれを出力してもよい。
入力例 1
pop
出力例 1
o
pop に o は 1 度だけ含まれます。
入力例 2
abc
出力例 2
a
abc に a, b, c はどれも 1 度だけ含まれるので、どれを出力しても構いません。
入力例 3
xxx
出力例 3
-1
xxx に 1 度だけ含まれる文字はありません。
Score : 100 points
Problem Statement
You are given a string S of length 3.
Print a character that occurs only once in S.
If there is no such character, print -1 instead.
Constraints
- S is a string of length 3 consisting of lowercase English letters.
Input
Input is given from Standard Input in the following format:
S
Output
Print the answer. If multiple solutions exist, you may print any of them.
Sample Input 1
pop
Sample Output 1
o
o occurs only once in pop.
Sample Input 2
abc
Sample Output 2
a
a, b, and c occur once each in abc, so you may print any of them.
Sample Input 3
xxx
Sample Output 3
-1
No character occurs only once in xxx.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
正の整数 X について、レベル X の 龍文字列 とは、1 個の L, X 個の o, 1 個の n, 1 個の g をこの順に並べた長さ (X+3) の文字列です。
正の整数 N が与えられるので、レベル N の龍文字列を出力してください。
大文字と小文字は区別されることに注意してください。
制約
- 1\leq N\leq 2024
- N は整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
レベル N の龍文字列を出力せよ。
入力例 1
3
出力例 1
Looong
1 個の L, 3 個の o, 1 個の n, 1 個の g をこの順に並べた文字列は Looong です。
入力例 2
1
出力例 2
Long
Score: 100 points
Problem Statement
For a positive integer X, the Dragon String of level X is a string of length (X+3) formed by one L, X occurrences of o, one n, and one g arranged in this order.
You are given a positive integer N. Print the Dragon String of level N.
Note that uppercase and lowercase letters are distinguished.
Constraints
- 1 \leq N \leq 2024
- N is an integer.
Input
The input is given from Standard Input in the following format:
N
Output
Print the Dragon String of level N.
Sample Input 1
3
Sample Output 1
Looong
Arranging one L, three os, one n, and one g in this order yields Looong.
Sample Input 2
1
Sample Output 2
Long
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
1,\ldots,N の番号のついた N 人の選手がゲームを行いました。選手 i のスコアは A_i であり、スコアが小さい方が上位になります。
ブービー賞に該当する選手、すなわち、下位から 2 番目の選手の番号を求めてください。
制約
- 2 \leq N \leq 2\times 10^5
- 1 \leq A_i \leq 10^9
- A_i は相異なる
- 入力に含まれる値は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
N A_1 \ldots A_N
出力
答えを出力せよ。
入力例 1
6 1 123 12345 12 1234 123456
出力例 1
3
6 人中 5 位になるのは、選手 3 です。
入力例 2
5 3 1 4 15 9
出力例 2
5
Score : 200 points
Problem Statement
N players, who are numbered 1, \ldots, N, have played a game. Player i has scored A_i, and a player with a smaller score ranks higher.
The player who ranks the second lowest will receive a booby prize. Who is this player? Answer with an integer representing the player.
Constraints
- 2 \leq N \leq 2\times 10^5
- 1 \leq A_i \leq 10^9
- A_i are distinct.
- 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
6 1 123 12345 12 1234 123456
Sample Output 1
3
It is Player 3 who ranks fifth among the six players.
Sample Input 2
5 3 1 4 15 9
Sample Output 2
5
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.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
正整数 x,y に対して f(x,y) を「(x+y) を 10^8 で割ったあまり」として定義します。
長さ N の正整数列 A=(A_1,\ldots,A_N) が与えられます。次の式の値を求めてください。
制約
- 2\leq N\leq 3\times 10^5
- 1\leq A_i < 10^8
- 入力される数値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 \ldots A_N
出力
答えを出力せよ。
入力例 1
3 3 50000001 50000002
出力例 1
100000012
- f(A_1,A_2)=50000004
- f(A_1,A_3)=50000005
- f(A_2,A_3)=3
なので、答えは f(A_1,A_2)+f(A_1,A_3)+f(A_2,A_3) = 100000012 です。
総和を 10^8 で割ったあまりを求めるわけではないことに注意してください。
入力例 2
5 1 3 99999999 99999994 1000000
出力例 2
303999988
Score: 300 points
Problem Statement
For positive integers x and y, define f(x, y) as the remainder of (x + y) divided by 10^8.
You are given a sequence of positive integers A = (A_1, \ldots, A_N) of length N. Find the value of the following expression:
Constraints
- 2 \leq N \leq 3\times 10^5
- 1 \leq A_i < 10^8
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 \ldots A_N
Output
Print the answer.
Sample Input 1
3 3 50000001 50000002
Sample Output 1
100000012
- f(A_1,A_2)=50000004
- f(A_1,A_3)=50000005
- f(A_2,A_3)=3
Thus, the answer is f(A_1,A_2) + f(A_1,A_3) + f(A_2,A_3) = 100000012.
Note that you are not asked to compute the remainder of the sum divided by 10^8.
Sample Input 2
5 1 3 99999999 99999994 1000000
Sample Output 2
303999988