Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
チーム高橋とチーム青木が N 回の試合を行いました。 i 回め (1\leq i\leq N) の試合ではチーム高橋が X _ i 点、チーム青木が Y _ i 点を獲得しました。
N 回の試合で獲得した得点の合計がより多いチームの勝ちです。
どちらのチームが勝ったか出力してください。 ただし、獲得した得点の合計が等しい場合は引き分けとなります。
制約
- 1\leq N\leq 100
- 0\leq X _ i\leq 100\ (1\leq i\leq N)
- 0\leq Y _ i\leq 100\ (1\leq i\leq N)
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N X _ 1 Y _ 1 X _ 2 Y _ 2 \vdots X _ N Y _ N
出力
チーム高橋が勝った場合 Takahashi を、チーム青木が勝った場合 Aoki を、引き分けの場合 Draw を出力せよ。
入力例 1
4 10 2 10 1 10 2 3 2
出力例 1
Takahashi
4 回の試合で、チーム高橋は 33 点、チーム青木は 7 点を獲得しました。
チーム高橋が勝ったため、Takahashi を出力してください。
入力例 2
6 5 4 4 5 2 4 1 6 7 1 3 2
出力例 2
Draw
いずれのチームも 22 点を獲得しました。
引き分けなので、Draw を出力してください。
入力例 3
4 0 0 10 10 50 50 0 100
出力例 3
Aoki
一方もしくは両方のチームが、一試合のうちに 1 点も取れない場合もあります。
Score: 100 points
Problem Statement
Team Takahashi and Team Aoki played N matches. In the i-th match (1\leq i\leq N), Team Takahashi scored X _ i points, and Team Aoki scored Y _ i points.
The team with the higher total score from the N matches wins.
Print the winner. If the two teams have the same total score, it is a draw.
Constraints
- 1\leq N\leq 100
- 0\leq X _ i\leq 100\ (1\leq i\leq N)
- 0\leq Y _ i\leq 100\ (1\leq i\leq N)
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N X _ 1 Y _ 1 X _ 2 Y _ 2 \vdots X _ N Y _ N
Output
If Team Takahashi wins, print Takahashi; if Team Aoki wins, print Aoki; if it is a draw, print Draw.
Sample Input 1
4 10 2 10 1 10 2 3 2
Sample Output 1
Takahashi
In four matches, Team Takahashi scored 33 points, and Team Aoki scored 7 points.
Team Takahashi wins, so print Takahashi.
Sample Input 2
6 5 4 4 5 2 4 1 6 7 1 3 2
Sample Output 2
Draw
Both teams scored 22 points.
It is a draw, so print Draw.
Sample Input 3
4 0 0 10 10 50 50 0 100
Sample Output 3
Aoki
One or both teams may score no points in a match.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
ある OS のバージョンは古い順に "Ocelot", "Serval", "Lynx" です。
バージョン X がバージョン Y 以降のバージョンであるか判定してください。
なお、バージョン X 自身もバージョン X 以降のバージョンであるものとします。
制約
- X,Y は "
Ocelot", "Serval", "Lynx" のいずれか (引用符を含まない)
入力
入力は以下の形式で標準入力から与えられる。
X Y
出力
バージョン X がバージョン Y 以降のバージョンであれば Yes 、そうでなければ No と出力せよ。
入力例 1
Serval Ocelot
出力例 1
Yes
バージョン Serval はバージョン Ocelot 以降のバージョンです。そのため、 Yes と出力します。
入力例 2
Serval Lynx
出力例 2
No
バージョン Serval はバージョン Lynx 以降のバージョンではありません。そのため、 No と出力します。
入力例 3
Ocelot Ocelot
出力例 3
Yes
バージョン Ocelot 自身もバージョン Ocelot 以降のバージョンです。そのため、 Yes と出力します。
Score : 100 points
Problem Statement
The versions of a certain OS in chronological order are "Ocelot", "Serval", "Lynx".
Determine whether version X is the same as or newer than version Y.
Constraints
- Each of X and Y is one of "
Ocelot", "Serval", "Lynx" (without quotation marks).
Input
The input is given from Standard Input in the following format:
X Y
Output
If version X is the same as or newer than version Y, print Yes; otherwise, print No.
Sample Input 1
Serval Ocelot
Sample Output 1
Yes
Version Serval is the same as or newer than version Ocelot. Therefore, print Yes.
Sample Input 2
Serval Lynx
Sample Output 2
No
Version Serval is not the same as nor newer than version Lynx. Therefore, print No.
Sample Input 3
Ocelot Ocelot
Sample Output 3
Yes
Version Ocelot itself is the same as or newer than version Ocelot. Therefore, print Yes.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
高橋君は野球をモチーフにしたゲームを作ろうとしましたが、うまくコードが書けなくて困っています。
高橋君の代わりに次の問題を解くプログラムを作ってください。
マス 0, マス 1, マス 2, マス 3 の 4 つのマス目があります。はじめマスの上には何もありません。
また、整数 P があり、はじめ P = 0 です。
正の整数からなる数列 A = (A_1, A_2, \dots, A_N) が与えられるので、i = 1, 2, \dots, N について順番に次の操作を行います。
- マス 0 に駒を 1 個置く。
- マス上のすべての駒を番号が A_i 大きいマスに進める。言い換えると、駒がマス x にあればその駒をマス x + A_i に移動する。
ただし移動先のマスが存在しない (すなわち x + A_i が 4 以上になる) 駒たちに関しては、それらを取り除いて P に取り除いた個数を加算する。
すべての操作を行った後の P の値を出力してください。
制約
- 1 \leq N \leq 100
- 1 \leq A_i \leq 4
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \dots A_N
出力
操作終了時点での P の値を出力せよ。
入力例 1
4 1 1 3 2
出力例 1
3
操作を説明すると次のようになり、操作終了時点での P の値は 3 になります。
- i=1 での操作
- マス 0 に駒を置く。この時点でマス 0 にコマが乗っている。
- すべての駒を 1 大きいマスに進める。移動を終えた時点でマス 1 に駒が乗っている。
- i=2 での操作
- マス 0 に駒を置く。この時点でマス 0, 1 にコマが乗っている。
- すべての駒を 1 大きいマスに進める。移動を終えた時点でマス 1, 2 に駒が乗っている。
- i=3 での操作
- マス 0 に駒を置く。この時点でマス 0, 1, 2 にコマが乗っている。
- すべての駒を 3 大きいマスに進める。
この時、マス 1,2 にある駒は移動先のマスが存在しないため (それぞれ 1+3=4,2+3=5 なので) 、盤上から取り除いて P に 2 を加算する。P の値は 2 になる。
移動を終えた時点でマス 3 に駒が乗っている。
- i=4 での操作
- マス 0 に駒を置く。この時点でマス 0, 3 にコマが乗っている。
- すべての駒を 2 大きいマスに進める。
この時、マス 3 にある駒は移動先のマスが存在しないため (3+2=5 なので) 、盤上から取り除いて P に 1 を加算する。P の値は 3 になる。
移動を終えた時点でマス 2 に駒が乗っている。
入力例 2
3 1 1 1
出力例 2
0
P の値が操作中に変化しない場合もあります。
入力例 3
10 2 2 4 1 1 1 4 2 2 1
出力例 3
8
Score : 200 points
Problem Statement
Takahashi is trying to create a game inspired by baseball, but he is having difficulty writing the code.
Write a program for Takahashi that solves the following problem.
There are 4 squares called Square 0, Square 1, Square 2, and Square 3. Initially, all squares are empty.
There is also an integer P; initially, P = 0.
Given a sequence of positive integers A = (A_1, A_2, \dots, A_N), perform the following operations for i = 1, 2, \dots, N in this order:
- Put a piece on Square 0.
- Advance every piece on the squares A_i squares ahead. In other words, if Square x has a piece, move the piece to Square (x + A_i).
If, however, the destination square does not exist (i.e. x + A_i is greater than or equal to 4) for a piece, remove it. Add to P the number of pieces that have been removed.
Print the value of P after all the operations have been performed.
Constraints
- 1 \leq N \leq 100
- 1 \leq A_i \leq 4
- 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
Output
Print the value of P after all the operations have been performed.
Sample Input 1
4 1 1 3 2
Sample Output 1
3
The operations are described below. After all the operations have been performed, P equals 3.
- The operations for i=1:
- Put a piece on Square 0. Now, Square 0 has a piece.
- Advance every piece on the squares 1 square ahead. After these moves, Square 1 has a piece.
- The operations for i=2:
- Put a piece on Square 0. Now, Squares 0 and 1 have a piece.
- Advance every piece on the squares 1 square ahead. After these moves, Squares 1 and 2 have a piece.
- The operations for i=3:
- Put a piece on Square 0. Now, Squares 0, 1, and 2 have a piece.
- Advance every piece on the squares 3 squares ahead.
Here, for the pieces on Squares 1 and 2, the destination squares do not exist (since 1+3=4 and 2+3=5), so remove these pieces and add 2 to P. P now equals 2. After these moves, Square 3 has a piece.
- The operations for i=4:
- Put a piece on Square 0. Now, Squares 0 and 3 have a piece.
- Advance every piece on the squares 2 squares ahead.
Here, for the piece on Square 3, the destination square does not exist (since 3+2=5), so remove this piece and add 1 to P. P now equals 3.
After these moves, Square 2 has a piece.
Sample Input 2
3 1 1 1
Sample Output 2
0
The value of P may not be updated by the operations.
Sample Input 3
10 2 2 4 1 1 1 4 2 2 1
Sample Output 3
8
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
配点 : 400 点
問題文
整数列 A=(A_1,A_2,\dots,A_N) があります。 あなたは次の操作を好きな回数(0 回でもよい)行うことができます。
- 1\leq i,j \leq N を満たす整数 i,j を選ぶ。A_i を 1 減らし、A_j を 1 増やす。
A の最小値と最大値の差を 1 以下にするために必要な最小の操作回数を求めてください。
制約
- 1\leq N \leq 2\times 10^5
- 1\leq A_i \leq 10^9
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \dots A_N
出力
答えを整数として出力せよ。
入力例 1
4 4 7 3 7
出力例 1
3
以下のように 3 回の操作を行うことで、A の最小値と最大値の差を 1 以下にすることができます。
- i=2,j=3 として操作を行う。A=(4,6,4,7) になる。
- i=4,j=1 として操作を行う。A=(5,6,4,6) になる。
- i=4,j=3 として操作を行う。A=(5,6,5,5) になる。
3 回未満の操作で A の最小値と最大値の差を 1 以下にすることはできません。よって答えは 3 です。
入力例 2
1 313
出力例 2
0
入力例 3
10 999999997 999999999 4 3 2 4 999999990 8 999999991 999999993
出力例 3
2499999974
Score : 400 points
Problem Statement
You are given an integer sequence A=(A_1,A_2,\dots,A_N). You can perform the following operation any number of times (possibly zero).
- Choose integers i and j with 1\leq i,j \leq N. Decrease A_i by one and increase A_j by one.
Find the minimum number of operations required to make the difference between the minimum and maximum values of A at most one.
Constraints
- 1\leq N \leq 2\times 10^5
- 1\leq A_i \leq 10^9
- 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 as an integer.
Sample Input 1
4 4 7 3 7
Sample Output 1
3
By the following three operations, the difference between the minimum and maximum values of A becomes at most one.
- Choose i=2 and j=3 to make A=(4,6,4,7).
- Choose i=4 and j=1 to make A=(5,6,4,6).
- Choose i=4 and j=3 to make A=(5,6,5,5).
You cannot make the difference between maximum and minimum values of A at most one by less than three operations, so the answer is 3.
Sample Input 2
1 313
Sample Output 2
0
Sample Input 3
10 999999997 999999999 4 3 2 4 999999990 8 999999991 999999993
Sample Output 3
2499999974