Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
与えられる 5 つの整数 A, B, C, D, E の中に何種類の整数があるかを出力してください。
制約
- 0 \leq A, B, C, D, E \leq 100
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
A B C D E
出力
答えを出力せよ。
入力例 1
31 9 24 31 24
出力例 1
3
与えられる 5 つの整数 31, 9, 24, 31, 24 の中には、9, 24, 31 という 3 種類の整数があります。 よって、3 を出力します。
入力例 2
0 0 0 0 0
出力例 2
1
Score : 100 points
Problem Statement
Print how many distinct integers there are in given five integers A, B, C, D, and E.
Constraints
- 0 \leq A, B, C, D, E \leq 100
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C D E
Output
Print the answer.
Sample Input 1
31 9 24 31 24
Sample Output 1
3
In the given five integers 31, 9, 24, 31, and 24, there are three distinct integers 9, 24, and 31. Thus, 3 should be printed.
Sample Input 2
0 0 0 0 0
Sample Output 2
1
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
現在 AtCoder で開催されている AtCoder Regular Contest (ARC) には、Div. 1 と Div. 2 の 2 種類が存在します。 ARC Div. 1 では レーティング が 1600 以上 2999 以下の人が、ARC Div. 2 ではレーティングが 1200 以上 2399 以下の人がそれぞれ Rated 対象 となります。
正整数 R, X が与えられます。
レーティングが R の人は ARC Div. X において Rated 対象ですか?
制約
- 1\leq R \leq 4229
- 1\leq X \leq 2
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
R X
出力
レーティングが R の人が ARC Div. X において Rated 対象ならば Yes を、そうでないならば No を出力せよ。
入力例 1
2000 1
出力例 1
Yes
2000 は 1600 以上 2999 以下であるため、レーティングが 2000 の人は ARC Div. 1 において Rated 対象です。
入力例 2
1000 1
出力例 2
No
1000 は 1600 未満であるため、レーティングが 1000 の人は ARC Div. 1 において Rated 対象ではありません。
入力例 3
1500 2
出力例 3
Yes
1500 は 1200 以上 2399 以下であるため、レーティングが 1500 の人は ARC Div. 2 において Rated 対象です。
入力例 4
2800 2
出力例 4
No
2800 は 2399 より大きいため、レーティングが 2800 の人は ARC Div. 2 において Rated 対象ではありません。
Score : 100 points
Problem Statement
AtCoder Regular Contest (ARC) currently has two divisions: Div. 1 and Div. 2. In ARC Div. 1, participants whose rating is between 1600 and 2999, inclusive, are rated. In ARC Div. 2, participants whose rating is between 1200 and 2399, inclusive, are rated.
You are given positive integers R and X.
Determine whether a person with rating R is rated in ARC Div. X.
Constraints
- 1 \le R \le 4229
- 1 \le X \le 2
- All input values are integers.
Input
The input is given from Standard Input in the following format:
R X
Output
If a person with rating R is rated in ARC Div. X, output Yes; otherwise, output No.
Sample Input 1
2000 1
Sample Output 1
Yes
Because 2000 lies between 1600 and 2999, a person with rating 2000 is rated in ARC Div. 1.
Sample Input 2
1000 1
Sample Output 2
No
Because 1000 is less than 1600, a person with rating 1000 is not rated in ARC Div. 1.
Sample Input 3
1500 2
Sample Output 3
Yes
Because 1500 lies between 1200 and 2399, a person with rating 1500 is rated in ARC Div. 2.
Sample Input 4
2800 2
Sample Output 4
No
Because 2800 exceeds 2399, a person with rating 2800 is not rated in ARC Div. 2.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
N + 1 個の部屋が一列に並んでおり、順に 0, 1, \ldots, N の番号が付けられています。
部屋の間には N 個のドアがあり、1, 2, \ldots, N の番号が付けられています。ドア i は部屋 i - 1 と部屋 i の間にあります。
各ドアについて鍵の状態を表す値 L_i が与えられ、L_i = 0 のときドア i の鍵は開いており、L_i = 1 のときドア i の鍵は閉まっています。
2 人の人がおり、1 人は部屋 0 に、もう 1 人は部屋 N にいます。それぞれの人は、ドア i の鍵が開いているときに限り、部屋 i - 1 と部屋 i の間を移動することができます。
このとき、2 人のいずれも到達できない部屋の個数を求めてください。
制約
- 2 \leq N \leq 100
- L_i \in \lbrace 0, 1 \rbrace
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N L_1 L_2 \ldots L_N
出力
答えを出力せよ。
入力例 1
5 0 1 0 0 1
出力例 1
3
2 人のいずれも到達できない部屋は部屋 2, 3, 4 の 3 つです。
入力例 2
3 1 0 1
出力例 2
2
入力例 3
8 0 0 1 1 0 1 0 0
出力例 3
3
Score : 200 points
Problem Statement
There are N + 1 rooms arranged in a line, numbered 0, 1, \ldots, N in order.
Between the rooms, there are N doors numbered 1, 2, \ldots, N. Door i is between rooms i - 1 and i.
For each door, a value L_i representing the lock state is given. When L_i = 0, door i is unlocked, and when L_i = 1, door i is locked.
There are two people, one in room 0 and the other in room N. Each person can move between rooms i - 1 and i only when door i is unlocked.
Find the number of rooms that neither of the two people can reach.
Constraints
- 2 \leq N \leq 100
- L_i \in \lbrace 0, 1 \rbrace
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N L_1 L_2 \ldots L_N
Output
Output the answer.
Sample Input 1
5 0 1 0 0 1
Sample Output 1
3
The rooms that neither of the two people can reach are rooms 2, 3, 4, which is 3 rooms.
Sample Input 2
3 1 0 1
Sample Output 2
2
Sample Input 3
8 0 0 1 1 0 1 0 0
Sample Output 3
3
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
AtCoder では現在、 ABC , ARC , AGC , AHC の 4 つのコンテストが定期的に開催されています。
AtCoder で現在定期的に開催されているコンテストは S_1 , S_2 , S_3 とあと 1 つは何ですか?
制約
- S_1 , S_2 , S_3 はそれぞれ、
ABC,ARC,AGC,AHCのいずれかである。 - S_1 , S_2 , S_3 は相異なる。
入力
入力は以下の形式で標準入力から与えられる。
S_1 S_2 S_3
出力
答えを出力せよ。
入力例 1
ARC AGC AHC
出力例 1
ABC
ARC , AGC , AHC の 3つが入力として与えられているので、
残りの 1 つはABC です。
入力例 2
AGC ABC ARC
出力例 2
AHC
Score : 200 points
Problem Statement
AtCoder currently holds four series of regular contests: ABC, ARC, AGC, and AHC.
What is the series of regular contests currently held by AtCoder in addition to S_1, S_2, and S_3?
Constraints
- Each of S_1, S_2, and S_3 is
ABC,ARC,AGC, orAHC. - S_1, S_2, and S_3 are pairwise different.
Input
Input is given from Standard Input in the following format:
S_1 S_2 S_3
Output
Print the answer.
Sample Input 1
ARC AGC AHC
Sample Output 1
ABC
Given in input are ARC, AGC, and AHC. The rest is ABC.
Sample Input 2
AGC ABC ARC
Sample Output 2
AHC
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 250 点
問題文
長さ N の正整数列 A=(A_1,A_2,\dots,A_N) および正整数 K が与えられます。
1 以上 K 以下の整数のうち、A の中に一度も現れないものの総和を求めてください。
制約
- 1\leq N \leq 2\times 10^5
- 1\leq K \leq 2\times 10^9
- 1\leq A_i \leq 2\times 10^9
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N K A_1 A_2 \dots A_N
出力
答えを出力せよ。
入力例 1
4 5 1 6 3 1
出力例 1
11
1 以上 5 以下の整数のうち、A の中に一度も現れないものは 2,4,5 の 3 つです。
よって、それらの総和である 2+4+5=11 を出力します。
入力例 2
1 3 346
出力例 2
6
入力例 3
10 158260522 877914575 24979445 623690081 262703497 24979445 1822804784 1430302156 1161735902 923078537 1189330739
出力例 3
12523196466007058
Score: 250 points
Problem Statement
You are given a sequence of positive integers A=(A_1,A_2,\dots,A_N) of length N and a positive integer K.
Find the sum of the integers between 1 and K, inclusive, that do not appear in the sequence A.
Constraints
- 1\leq N \leq 2\times 10^5
- 1\leq K \leq 2\times 10^9
- 1\leq A_i \leq 2\times 10^9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N K A_1 A_2 \dots A_N
Output
Print the answer.
Sample Input 1
4 5 1 6 3 1
Sample Output 1
11
Among the integers between 1 and 5, three numbers, 2, 4, and 5, do not appear in A.
Thus, print their sum: 2+4+5=11.
Sample Input 2
1 3 346
Sample Output 2
6
Sample Input 3
10 158260522 877914575 24979445 623690081 262703497 24979445 1822804784 1430302156 1161735902 923078537 1189330739
Sample Output 3
12523196466007058