実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
高橋君は自分の体温を計測し、 X {}^\circC であることがわかりました。
体温は次の 3 種類に分類されます。
- 38.0 {}^\circC 以上のとき「高熱」
- 37.5 {}^\circC 以上 38.0 {}^\circC 未満のとき「発熱」
- 37.5 {}^\circC 未満のとき「平熱」
高橋君の体温は何に分類されるでしょうか?「出力」の項にしたがって整数で出力してください。
制約
- 30 \leq X \leq 50
- X は小数第一位まで与えられる
入力
入力は以下の形式で標準入力から与えられる。
X
出力
高橋君の体温が何に分類されるかを以下に定められる整数で出力せよ。
- 高熱の場合: 1
- 発熱の場合: 2
- 平熱の場合: 3
入力例 1
40.0
出力例 1
1
高橋君の体温は 40.0 {}^\circC であるため、高熱に分類されます。よって、1 を出力します。
入力例 2
37.7
出力例 2
2
高橋君の体温は 37.7 {}^\circC であるため、発熱に分類されます。よって、2 を出力します。
入力例 3
36.6
出力例 3
3
高橋君の体温は 36.6 {}^\circC であるため、平熱に分類されます。よって、3 を出力します。
Score : 100 points
Problem Statement
Takahashi measured his body temperature and found it to be X {}^\circC.
Body temperature is classified into the following:
- Higher than or equal to 38.0 {}^\circC: “High fever”
- Higher than or equal to 37.5 {}^\circC and lower than 38.0 {}^\circC: “Fever”
- Lower than 37.5 {}^\circC: “Normal”
Which classification does Takahashi's body temperature fall into? Present the answer as an integer according to the Output section.
Constraints
- 30 \leq X \leq 50
- X is given to one decimal place.
Input
The input is given from Standard Input in the following format:
X
Output
Print an integer specified below corresponding to Takahashi's body temperature classification.
- High fever: 1
- Fever: 2
- Normal: 3
Sample Input 1
40.0
Sample Output 1
1
His body temperature is 40.0 {}^\circC, which is classified as a high fever. Thus, print 1.
Sample Input 2
37.7
Sample Output 2
2
His body temperature is 37.7 {}^\circC, which is classified as a fever. Thus, print 2.
Sample Input 3
36.6
Sample Output 3
3
His body temperature is 36.6 {}^\circC, which is classified as a normal temperature. Thus, print 3.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
1 以上 9 以下の整数 N が入力として与えられます。
数字 N を N 個繋げて得られる文字列を出力してください。
制約
- N は 1 以上 9 以下の整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
答えを出力せよ。
入力例 1
3
出力例 1
333
3 を 3 個繋げて得られる文字列は 333 です。
入力例 2
9
出力例 2
999999999
Score : 100 points
Problem Statement
You are given an integer N between 1 and 9, inclusive, as input.
Concatenate N copies of the digit N and print the resulting string.
Constraints
- N is an integer between 1 and 9, inclusive.
Input
The input is given from Standard Input in the following format:
N
Output
Print the answer.
Sample Input 1
3
Sample Output 1
333
Concatenate three copies of the digit 3 to yield the string 333.
Sample Input 2
9
Sample Output 2
999999999
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
N 人の人が総当り戦の試合をしました。
N 行 N 列からなる試合の結果の表 A が与えられます。A の i 行目 j 列目の要素を A_{i,j} と表します。
A_{i,j} は i=j のとき - であり、それ以外のとき W, L, D のいずれかです。
A_{i,j} が W, L, D であることは、人 i が人 j との試合に勝った、負けた、引き分けたことをそれぞれ表します。
与えられた表に矛盾があるかどうかを判定してください。
次のいずれかが成り立つとき、与えられた表には矛盾があるといいます。
- ある組 (i,j) が存在して、人 i が人 j に勝ったが、人 j が人 i に負けていない
- ある組 (i,j) が存在して、人 i が人 j に負けたが、人 j が人 i に勝っていない
- ある組 (i,j) が存在して、人 i が人 j に引き分けたが、人 j が人 i に引き分けていない
制約
- 2 \leq N \leq 1000
- A_{i,i} は
-である - i\neq j のとき、A_{i,j} は
W,L,Dのいずれかである
入力
入力は以下の形式で標準入力から与えられる。
N
A_{1,1}A_{1,2}\ldots A_{1,N}
A_{2,1}A_{2,2}\ldots A_{2,N}
\vdots
A_{N,1}A_{N,2}\ldots A_{N,N}
出力
与えられた表に矛盾がないとき correct、矛盾があるとき incorrect と出力せよ。
入力例 1
4 -WWW L-DD LD-W LDW-
出力例 1
incorrect
人 3 が人 4 に勝ったにもかかわらず、人 4 も人 3 に勝ったことになっており、矛盾しています。
入力例 2
2 -D D-
出力例 2
correct
矛盾はありません。
Score : 200 points
Problem Statement
N players played a round-robin tournament.
You are given an N-by-N table A containing the results of the matches. Let A_{i,j} denote the element at the i-th row and j-th column of A.
A_{i,j} is - if i=j, and W, L, or D otherwise.
A_{i,j} is W if Player i beat Player j, L if Player i lost to Player j, and D if Player i drew with Player j.
Determine whether the given table is contradictory.
The table is said to be contradictory when some of the following holds:
- There is a pair (i,j) such that Player i beat Player j, but Player j did not lose to Player i;
- There is a pair (i,j) such that Player i lost to Player j, but Player j did not beat Player i;
- There is a pair (i,j) such that Player i drew with Player j, but Player j did not draw with Player i.
Constraints
- 2 \leq N \leq 1000
- A_{i,i} is
-. - A_{i,j} is
W,L, orD, for i\neq j.
Input
Input is given from Standard Input in the following format:
N
A_{1,1}A_{1,2}\ldots A_{1,N}
A_{2,1}A_{2,2}\ldots A_{2,N}
\vdots
A_{N,1}A_{N,2}\ldots A_{N,N}
Output
If the given table is not contradictory, print correct; if it is contradictory, print incorrect.
Sample Input 1
4 -WWW L-DD LD-W LDW-
Sample Output 1
incorrect
Player 3 beat Player 4, while Player 4 also beat Player 3, which is contradictory.
Sample Input 2
2 -D D-
Sample Output 2
correct
There is no contradiction.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
横書きの文章が与えられます。縦書きに直してください。空白を
*で埋めてください。
N 個の、英小文字からなる文字列 S_1,S_2,\dots,S_N が与えられます。これらの文字列の長さの最大値を M とします。
以下の条件を満たす M 個の文字列 T_1,T_2,\dots,T_M を出力してください。
- 各 T_i は英小文字および
*からなる - 各 T_i の末尾は
*でない - 各 1 \leq i \leq N について、次が成り立つ
- 各 1 \leq j \leq |S_i| について、T_j の N-i+1 文字目が存在し、T_1,T_2,\dots,T_{|S_i|} それぞれの N-i+1 文字目をこの順に連結したものは S_i と一致する
- 各 |S_i| + 1 \leq j \leq M について、T_j の N-i+1 文字目は存在しないか、
*である
ただし、|S_i| で文字列 S_i の長さを表します。
制約
- N は 1 以上 100 以下の整数
- S_i は長さ 1 以上 100 以下の英小文字からなる文字列
入力
入力は以下の形式で標準入力から与えられる。
N S_1 S_2 \vdots S_N
出力
答えを以下の形式で出力せよ。
T_1 T_2 \vdots T_M
入力例 1
3 abc de fghi
出力例 1
fda geb h*c i
T_3 の 2 文字目を * とすることで、 c が正しい位置に来ます。
T_4 の 2,3 文字目を * とした場合、T_4 の末尾が * となり、条件を満たしません。
入力例 2
3 atcoder beginner contest
出力例 2
cba oet ngc tio end sne ter *r
Score : 200 points
Problem Statement
You are given a horizontally written text. Convert it to vertical writing, filling spaces with
*.
You are given N strings S_1, S_2, \dots, S_N consisting of lowercase English letters. Let M be the maximum length of these strings.
Print M strings T_1, T_2, \dots, T_M that satisfy the following conditions:
- Each T_i consists of lowercase English letters and
*. - Each T_i does not end with
*. - For each 1 \leq i \leq N, the following holds:
- For each 1 \leq j \leq |S_i|, the (N-i+1)-th character of T_j exists, and the concatenation of the (N-i+1)-th characters of T_1, T_2, \dots, T_{|S_i|} in this order equals S_i.
- For each |S_i| + 1 \leq j \leq M, the (N-i+1)-th character of T_j either does not exist or is
*.
Here, |S_i| denotes the length of the string S_i.
Constraints
- N is an integer between 1 and 100, inclusive.
- Each S_i is a string of lowercase English letters with length between 1 and 100, inclusive.
Input
The input is given from Standard Input in the following format:
N S_1 S_2 \vdots S_N
Output
Print the answer in the following format:
T_1 T_2 \vdots T_M
Sample Input 1
3 abc de fghi
Sample Output 1
fda geb h*c i
Placing * as the 2nd character of T_3 puts the c in the correct position.
On the other hand, placing * as the 2nd and 3rd characters of T_4 would make T_4 end with *, which violates the condition.
Sample Input 2
3 atcoder beginner contest
Sample Output 2
cba oet ngc tio end sne ter *r
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 300 点
問題文
キーエンス本社に勤務する人数が増えてきたので、本社に存在する部署を 2 つのグループに分け、昼休みの時間帯を分けることにしました。
キーエンス本社には N 個の部署が存在し、i 番目 (1\leq i\leq N) の部署に所属する人数は K_i 人です。
それぞれの部署をグループ A, B のいずれか一方に割り当て、グループごとに同時に昼休みをとり、
かつグループ A, B の昼休みの時間が重ならないようにしたとき、同時に昼休みをとる最大人数としてあり得る最小の値を求めてください。
すなわち、グループ A に割り当てられた部署に所属する人数の合計とグループ B に割り当てられた部署に所属する人数の合計
のうち大きい方の値としてあり得る最小の値を求めてください。
制約
- 2\leq N \leq 20
- 1\leq K_i \leq 10^8
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N K_1 K_2 \ldots K_N
出力
同時に昼休みを取る最大人数としてあり得る最小の値を出力せよ。
入力例 1
5 2 3 5 10 12
出力例 1
17
1,2,5 番目の部署をグループ A に、3,4 番目の部署をグループ B に割り当てたとき、 グループ A に割り当てられた部署に所属する人数の合計は 2+3+12=17 、 グループ B に割り当てられた部署に所属する人数の合計は 5+10=15 となり、 このとき同時に昼休みを取る最大人数は 17 となります。
一方で、グループ A,B それぞれに割り当てられた部署に所属する人数の合計がいずれも 16 以下になるように 部署を割り当てることはできないため、17 を出力します。
入力例 2
2 1 1
出力例 2
1
同一人数の部署が複数存在する可能性もあります。
入力例 3
6 22 25 26 45 22 31
出力例 3
89
例えば、1,4,5 番目の部署をグループ A に、2,3,6 番目の部署をグループ B に割り当てたとき同時に昼休みを取る最大人数は 89 となります。
Score : 300 points
Problem Statement
As KEYENCE headquarters have more and more workers, they decided to divide the departments in the headquarters into two groups and stagger their lunch breaks.
KEYENCE headquarters have N departments, and the number of people in the i-th department (1\leq i\leq N) is K_i.
When assigning each department to Group A or Group B, having each group take lunch breaks at the same time, and ensuring that the lunch break times of Group A and Group B do not overlap, find the minimum possible value of the maximum number of people taking a lunch break at the same time.
In other words, find the minimum possible value of the larger of the following: the total number of people in departments assigned to Group A, and the total number of people in departments assigned to Group B.
Constraints
- 2 \leq N \leq 20
- 1 \leq K_i \leq 10^8
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N K_1 K_2 \ldots K_N
Output
Print the minimum possible value of the maximum number of people taking a lunch break at the same time.
Sample Input 1
5 2 3 5 10 12
Sample Output 1
17
When assigning departments 1, 2, and 5 to Group A, and departments 3 and 4 to Group B, Group A has a total of 2+3+12=17 people, and Group B has a total of 5+10=15 people. Thus, the maximum number of people taking a lunch break at the same time is 17.
It is impossible to assign the departments so that both groups have 16 or fewer people, so print 17.
Sample Input 2
2 1 1
Sample Output 2
1
Multiple departments may have the same number of people.
Sample Input 3
6 22 25 26 45 22 31
Sample Output 3
89
For example, when assigning departments 1, 4, and 5 to Group A, and departments 2, 3, and 6 to Group B, the maximum number of people taking a lunch break at the same time is 89.