output_description stringlengths 15 956 | submission_id stringlengths 10 10 | status stringclasses 3 values | problem_id stringlengths 6 6 | input_description stringlengths 9 2.55k | attempt stringlengths 1 13.7k | problem_description stringlengths 7 5.24k | samples stringlengths 2 2.72k |
|---|---|---|---|---|---|---|---|
If the judge can return the string `AC` as a verdict to a program, print
`Yes`; if it cannot, print `No`.
* * * | s067697793 | Wrong Answer | p03567 | Input is given from Standard Input in the following format:
S | print(["Yes", "No"]["AC" in input()])
| Statement
Snuke built an online judge to hold a programming contest.
When a program is submitted to the judge, the judge returns a verdict, which
is a two-character string that appears in the string S as a contiguous
substring. (The judge can return any two-character substring of S.)
Determine whether the judge can return the string `AC` as the verdict to a
program. | [{"input": "BACD", "output": "Yes\n \n\nThe string `AC` appears in `BACD` as a contiguous substring (the second and\nthird characters).\n\n* * *"}, {"input": "ABCD", "output": "No\n \n\nAlthough the string `ABCD` contains both `A` and `C` (the first and third\ncharacters), the string `AC` does not appear in `ABCD` as a contiguous\nsubstring.\n\n* * *"}, {"input": "CABD", "output": "No\n \n\n* * *"}, {"input": "ACACA", "output": "Yes\n \n\n* * *"}, {"input": "XX", "output": "No"}] |
If the judge can return the string `AC` as a verdict to a program, print
`Yes`; if it cannot, print `No`.
* * * | s170351405 | Runtime Error | p03567 | Input is given from Standard Input in the following format:
S | if "AC" in input():
print("Yes")
else
print("No") | Statement
Snuke built an online judge to hold a programming contest.
When a program is submitted to the judge, the judge returns a verdict, which
is a two-character string that appears in the string S as a contiguous
substring. (The judge can return any two-character substring of S.)
Determine whether the judge can return the string `AC` as the verdict to a
program. | [{"input": "BACD", "output": "Yes\n \n\nThe string `AC` appears in `BACD` as a contiguous substring (the second and\nthird characters).\n\n* * *"}, {"input": "ABCD", "output": "No\n \n\nAlthough the string `ABCD` contains both `A` and `C` (the first and third\ncharacters), the string `AC` does not appear in `ABCD` as a contiguous\nsubstring.\n\n* * *"}, {"input": "CABD", "output": "No\n \n\n* * *"}, {"input": "ACACA", "output": "Yes\n \n\n* * *"}, {"input": "XX", "output": "No"}] |
If the judge can return the string `AC` as a verdict to a program, print
`Yes`; if it cannot, print `No`.
* * * | s103677020 | Runtime Error | p03567 | Input is given from Standard Input in the following format:
S | print('YNeos'['AC'in input()::2] | Statement
Snuke built an online judge to hold a programming contest.
When a program is submitted to the judge, the judge returns a verdict, which
is a two-character string that appears in the string S as a contiguous
substring. (The judge can return any two-character substring of S.)
Determine whether the judge can return the string `AC` as the verdict to a
program. | [{"input": "BACD", "output": "Yes\n \n\nThe string `AC` appears in `BACD` as a contiguous substring (the second and\nthird characters).\n\n* * *"}, {"input": "ABCD", "output": "No\n \n\nAlthough the string `ABCD` contains both `A` and `C` (the first and third\ncharacters), the string `AC` does not appear in `ABCD` as a contiguous\nsubstring.\n\n* * *"}, {"input": "CABD", "output": "No\n \n\n* * *"}, {"input": "ACACA", "output": "Yes\n \n\n* * *"}, {"input": "XX", "output": "No"}] |
If the judge can return the string `AC` as a verdict to a program, print
`Yes`; if it cannot, print `No`.
* * * | s382302124 | Runtime Error | p03567 | Input is given from Standard Input in the following format:
S | print("Yes") "AC" in input() else "No" | Statement
Snuke built an online judge to hold a programming contest.
When a program is submitted to the judge, the judge returns a verdict, which
is a two-character string that appears in the string S as a contiguous
substring. (The judge can return any two-character substring of S.)
Determine whether the judge can return the string `AC` as the verdict to a
program. | [{"input": "BACD", "output": "Yes\n \n\nThe string `AC` appears in `BACD` as a contiguous substring (the second and\nthird characters).\n\n* * *"}, {"input": "ABCD", "output": "No\n \n\nAlthough the string `ABCD` contains both `A` and `C` (the first and third\ncharacters), the string `AC` does not appear in `ABCD` as a contiguous\nsubstring.\n\n* * *"}, {"input": "CABD", "output": "No\n \n\n* * *"}, {"input": "ACACA", "output": "Yes\n \n\n* * *"}, {"input": "XX", "output": "No"}] |
If the judge can return the string `AC` as a verdict to a program, print
`Yes`; if it cannot, print `No`.
* * * | s044004601 | Runtime Error | p03567 | Input is given from Standard Input in the following format:
S | printf("Hello")
| Statement
Snuke built an online judge to hold a programming contest.
When a program is submitted to the judge, the judge returns a verdict, which
is a two-character string that appears in the string S as a contiguous
substring. (The judge can return any two-character substring of S.)
Determine whether the judge can return the string `AC` as the verdict to a
program. | [{"input": "BACD", "output": "Yes\n \n\nThe string `AC` appears in `BACD` as a contiguous substring (the second and\nthird characters).\n\n* * *"}, {"input": "ABCD", "output": "No\n \n\nAlthough the string `ABCD` contains both `A` and `C` (the first and third\ncharacters), the string `AC` does not appear in `ABCD` as a contiguous\nsubstring.\n\n* * *"}, {"input": "CABD", "output": "No\n \n\n* * *"}, {"input": "ACACA", "output": "Yes\n \n\n* * *"}, {"input": "XX", "output": "No"}] |
If the judge can return the string `AC` as a verdict to a program, print
`Yes`; if it cannot, print `No`.
* * * | s289087325 | Runtime Error | p03567 | Input is given from Standard Input in the following format:
S | a=input()
if “AC” in a:
print(“Yes”)
else:print(“No”) | Statement
Snuke built an online judge to hold a programming contest.
When a program is submitted to the judge, the judge returns a verdict, which
is a two-character string that appears in the string S as a contiguous
substring. (The judge can return any two-character substring of S.)
Determine whether the judge can return the string `AC` as the verdict to a
program. | [{"input": "BACD", "output": "Yes\n \n\nThe string `AC` appears in `BACD` as a contiguous substring (the second and\nthird characters).\n\n* * *"}, {"input": "ABCD", "output": "No\n \n\nAlthough the string `ABCD` contains both `A` and `C` (the first and third\ncharacters), the string `AC` does not appear in `ABCD` as a contiguous\nsubstring.\n\n* * *"}, {"input": "CABD", "output": "No\n \n\n* * *"}, {"input": "ACACA", "output": "Yes\n \n\n* * *"}, {"input": "XX", "output": "No"}] |
If the judge can return the string `AC` as a verdict to a program, print
`Yes`; if it cannot, print `No`.
* * * | s020152746 | Runtime Error | p03567 | Input is given from Standard Input in the following format:
S | S = input()
flag = False
for i in range(4):
if S[i:i+2] == "AC"
flag = True
print("Yes" if flag else "No") | Statement
Snuke built an online judge to hold a programming contest.
When a program is submitted to the judge, the judge returns a verdict, which
is a two-character string that appears in the string S as a contiguous
substring. (The judge can return any two-character substring of S.)
Determine whether the judge can return the string `AC` as the verdict to a
program. | [{"input": "BACD", "output": "Yes\n \n\nThe string `AC` appears in `BACD` as a contiguous substring (the second and\nthird characters).\n\n* * *"}, {"input": "ABCD", "output": "No\n \n\nAlthough the string `ABCD` contains both `A` and `C` (the first and third\ncharacters), the string `AC` does not appear in `ABCD` as a contiguous\nsubstring.\n\n* * *"}, {"input": "CABD", "output": "No\n \n\n* * *"}, {"input": "ACACA", "output": "Yes\n \n\n* * *"}, {"input": "XX", "output": "No"}] |
If the judge can return the string `AC` as a verdict to a program, print
`Yes`; if it cannot, print `No`.
* * * | s421360855 | Accepted | p03567 | Input is given from Standard Input in the following format:
S | print(["Yes", "No"][not (input().count("AC"))])
| Statement
Snuke built an online judge to hold a programming contest.
When a program is submitted to the judge, the judge returns a verdict, which
is a two-character string that appears in the string S as a contiguous
substring. (The judge can return any two-character substring of S.)
Determine whether the judge can return the string `AC` as the verdict to a
program. | [{"input": "BACD", "output": "Yes\n \n\nThe string `AC` appears in `BACD` as a contiguous substring (the second and\nthird characters).\n\n* * *"}, {"input": "ABCD", "output": "No\n \n\nAlthough the string `ABCD` contains both `A` and `C` (the first and third\ncharacters), the string `AC` does not appear in `ABCD` as a contiguous\nsubstring.\n\n* * *"}, {"input": "CABD", "output": "No\n \n\n* * *"}, {"input": "ACACA", "output": "Yes\n \n\n* * *"}, {"input": "XX", "output": "No"}] |
If the judge can return the string `AC` as a verdict to a program, print
`Yes`; if it cannot, print `No`.
* * * | s360508324 | Accepted | p03567 | Input is given from Standard Input in the following format:
S | print("Yes" if input().count("AC") >= 1 else "No")
| Statement
Snuke built an online judge to hold a programming contest.
When a program is submitted to the judge, the judge returns a verdict, which
is a two-character string that appears in the string S as a contiguous
substring. (The judge can return any two-character substring of S.)
Determine whether the judge can return the string `AC` as the verdict to a
program. | [{"input": "BACD", "output": "Yes\n \n\nThe string `AC` appears in `BACD` as a contiguous substring (the second and\nthird characters).\n\n* * *"}, {"input": "ABCD", "output": "No\n \n\nAlthough the string `ABCD` contains both `A` and `C` (the first and third\ncharacters), the string `AC` does not appear in `ABCD` as a contiguous\nsubstring.\n\n* * *"}, {"input": "CABD", "output": "No\n \n\n* * *"}, {"input": "ACACA", "output": "Yes\n \n\n* * *"}, {"input": "XX", "output": "No"}] |
If the judge can return the string `AC` as a verdict to a program, print
`Yes`; if it cannot, print `No`.
* * * | s723019922 | Runtime Error | p03567 | Input is given from Standard Input in the following format:
S | a = input()
if "AC" in a:
print("Yes")
elif:
print("No") | Statement
Snuke built an online judge to hold a programming contest.
When a program is submitted to the judge, the judge returns a verdict, which
is a two-character string that appears in the string S as a contiguous
substring. (The judge can return any two-character substring of S.)
Determine whether the judge can return the string `AC` as the verdict to a
program. | [{"input": "BACD", "output": "Yes\n \n\nThe string `AC` appears in `BACD` as a contiguous substring (the second and\nthird characters).\n\n* * *"}, {"input": "ABCD", "output": "No\n \n\nAlthough the string `ABCD` contains both `A` and `C` (the first and third\ncharacters), the string `AC` does not appear in `ABCD` as a contiguous\nsubstring.\n\n* * *"}, {"input": "CABD", "output": "No\n \n\n* * *"}, {"input": "ACACA", "output": "Yes\n \n\n* * *"}, {"input": "XX", "output": "No"}] |
If the judge can return the string `AC` as a verdict to a program, print
`Yes`; if it cannot, print `No`.
* * * | s453218782 | Wrong Answer | p03567 | Input is given from Standard Input in the following format:
S | print("YNeos"["AC" in input() :: 2])
| Statement
Snuke built an online judge to hold a programming contest.
When a program is submitted to the judge, the judge returns a verdict, which
is a two-character string that appears in the string S as a contiguous
substring. (The judge can return any two-character substring of S.)
Determine whether the judge can return the string `AC` as the verdict to a
program. | [{"input": "BACD", "output": "Yes\n \n\nThe string `AC` appears in `BACD` as a contiguous substring (the second and\nthird characters).\n\n* * *"}, {"input": "ABCD", "output": "No\n \n\nAlthough the string `ABCD` contains both `A` and `C` (the first and third\ncharacters), the string `AC` does not appear in `ABCD` as a contiguous\nsubstring.\n\n* * *"}, {"input": "CABD", "output": "No\n \n\n* * *"}, {"input": "ACACA", "output": "Yes\n \n\n* * *"}, {"input": "XX", "output": "No"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s431809405 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | deff main():
N, M = map(int, input().split())
if N >= M:
print(0)
exit()
X = [j for j in map(int, input().split())]
X.sort()
s = max(X)-min(X)
d = [X[i+1]-X[i] for i in range(M-1)]
d.sort()
print(s-sum(d[-N+1:]))
main()
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s645524870 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | def main():
N, M = map(int, input().split())
X = [j for j in map(int, input().split())]
if N >= M:
print(0)
exit()
X.sort()
s = max(X)-min(X)
d = [X[i+1]-X[i] for i in range(M-1)]
d.sort()
if N = 1:
print(s-d[-1])
else:
print(s-sum(d[-N+1:]))
main()
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s218784747 | Accepted | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | import sys
s2nn = lambda s: [int(c) for c in s.split(" ")]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
# n: コマ
# x: 目的地 len(x)=M
def main(N, M, Xm):
# コマ数N >= 目的地数M: クリア
if N >= M:
print(0)
return
# 目的地は個体区別しないので、簡単のためソート
Xm.sort()
# コマ数N == 1: 1コマで端から端まで移動
if N == 1:
d = Xm[M - 1] - Xm[0]
print(d)
return
# 2 <= コマ数N < 目的地数M: どうする?
# 発想を変えて、目的地間の距離に注目
Dm = [Xm[i] - Xm[i - 1] for i in range(1, M)]
# 区間は、間隔が短い順に並ぶとする
Dm.sort()
# 全てのコマの移動方向は右とする
# コマ1は一番左の目的地からスタート
# コマ2~Nは右端の目的地から埋めていく
# 1 5 4 3 2 コマ
# x-x--x---x----x-----x------x-------x 目的地(区間が短い順)
# あとは、コマ1が、コマNの隣まで進めばよい、その距離が答えとなる
d = 0
for i in range(M - N):
d += Dm[i]
print(d)
N, M = i2nn()
Xm = i2nn()
main(N, M, Xm)
"""
C - Streamline
https://atcoder.jp/contests/abc117/tasks/abc117_c
2 5
10 12 1 2 14
5
3 7
-10 -3 0 9 -100 2 17
19
100 1
-100000
0
"""
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s131574049 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | N, M = (int(i) for i in input().split())
X = [int(i) for i in input().split()]
s= 0
if N >= M:
print(0)
else
X.sort()
for i in range(M-1):
lg_bw_x[i] = X[i+1] - X[i]
for i in range(M-N-1):
s = s+lg_bw_x[i]
print(s) | Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s828715645 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.sort()
c = []
if len(b) != 0:
for i in range(len(b) - 1):
c.append(b[i+1] - b[i])
if len(b) == 0:
print(1)
else:
for j in range(min(a[0] - 1,a[1]):
for k in range(len(c)):
if c[k] == max(c):
c[k] = 0
print(sum(c)) | Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s318583395 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | n,m=map(int,input().split())
x=[int(i) for i in input().split()]
if m==1 or n>m
print(0)
else:
x=sorted(x)
if n==1:
print(x[-1]-x[0])
else:
xsa=[]
for i in range(len(x)-1):
xsa.append(x[i+1]-x[i])
xsa=sorted(xsa)
print(sum(xsa[0:(m-n)]))
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s212635927 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | N,M = map(int,input().split())
X = list(map(int,input().split()))
if N > M :
print(0)
else:
flag = [0 for fl in range(M)]
X.sort()
for _ in range(1,M):
flag[_] += X[_] - X[_-1]
for lp in range(N-1):
flag.pop(flag.index(max(flag)))
print(sum(flag))
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s327088421 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | NM = [int(x) for x in input().split()]
N = NM[0]
M = NM[1]
X = [int(x) for x in input().split()]
X.sort()
print(X)
LL = 0
if N > M:
#print(LL)
else:
L = [0] * (M - 1)
for i in range (0, M - 1):
L[i] = X[i + 1] - X[i]
L.sort()
#print(L)
for i in range(0, M - N):
LL += L[i]
print(LL) | Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s863293267 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | n, m = map(int, input().split(" "))
X = list(map(int, input().split(" ")))
X.sort(reverse=True)
dis = []
div = 0
for i in range(m - 1):
dis.append(X[i + 1]=X[i])
dis.sort(Reverse=True)
for i in range(n - 1):
div += dis[i]
print(sum(dis) - div)
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s793892451 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | N, M = [int(n) for n in input().split()]
X = sorted([int(n) for n in input().split()])
if N>=M:
print(0)
else:
dx = []
for j in range(M-1):
dx.append(X[j+1]-X[j])
ans = sorted(dx, reverse=True)
print(sum(ans[N-1:])) | Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s608227527 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | n,m = map(int,input().split())
x = list(map(int,input().split()))
if m =< n:
print(0)
quit()
x.sort()
dist_l = [0] * (m-1)
for i in range(m-1):
dist_l[i] = x[i+1] - x[i]
dist_l.sort()
print(sum(dist_l[:-(n-1)])) | Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s369633559 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort(
y = []
for i in range(m - 1):
y.append(x[i + 1] - x[i])
y.sort()
count = 0
for i in range(m - n):
count += y[i]
print(count) | Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s514826761 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | n,m=map(int,input().split())
x=[int(i) for i in input().split()]
x.sort()
y=[]
if n-m>=0:
print(0)
exit(0)
else:
for i in range(n-1):
y.append(x[i+1]-x[i])
y.sort()
print(sum(y[:n-m])
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s066997790 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | N,M = map(int,(input().split()))
X = list(map(int,(input().split())))
X.sort()
if M > N:
dist = [X[i+1]-X[i] for i in range(M - 1)]
dist.sort(reverse = True)
del dist[0:N]
print(sum(dist))
else:
print(0) | Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s317890512 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | a,b = map(int,input().split())
lis = list(map(int,input().split()))
lis.sort()
ls=[]
for i in range(b-1):
ls.append(lis[i+1]-lis[i])
ls.sort()
print(sum(ls[n-1:])
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s281127430 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | print(d)
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s839455668 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | #include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <cmath>
using namespace std;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef double db;
typedef string str;
typedef vector<str> vs;
#define in(x) cin >> x
#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) str s; cin >> x
#define out(x) cout << x
#define outb(x) cout << x << ' '
#define outn(x) cout << x << '\n'
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz size()
#define len length()
#define all(x) x.begin(), x.end()
#define alln(a, n) a, a+n
#define forn(i, s, e) for (int i = s; i < e; i++)
#define forr(i, s, e) for (int i = s; i >= e; i--)
#define ford(i, s, e, d) for (int i = s; i < e; i += d)
#define fors(i, n) for (int i = 1; i*i <= n; i++)
const int MAX = (int)1e5 + 9;
int arr[MAX];
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
ini(n); ini(m);
forn(i, 0, m) in(arr[i]);
sort(alln(arr, m));
int md = arr[m-1] - arr[0];
vi d;
forn(i, 1, m) d.pb(arr[i] - arr[i-1]);
sort(all(d));
reverse(all(d));
forn(i, 0, n-1) md -= d[i];
outn(md);
return 0;
}
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s643878091 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321
#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif
using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}
vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
debug("debug test\n");
int n,m;cin>>n>>m;
vint x(m);
rep(i, m){
cin>>x[i];
}
if(n>=m){
cout << 0 << endl;
return 0;
}
sort(all(x));
vint aid;
ll sum = 0;
rep(i, m-1){
aid.push_back(x[i+1]-x[i]);
sum += x[i+1]-x[i];
}
sort(all(aid), greater<int>());
ll rem = 0;
rep(i, n-1){
rem += aid[i];
}
cout << sum - rem << endl;
return 0;
}
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s917548454 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | #define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size()) //size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
int main(void) {
int n, m,x[10005];
int max_sum=0;
cin >> n >> m;
REP(i, m)cin >> x[i];
if (n >= m) cout << "0" << endl;
else {
sort(x, x + m);
int diff[10005];
REP(i, m - 1) { diff[i] = x[i + 1] - x[i]; }
sort(diff, diff + (m - 1), std::greater<int>());
REP(i, n - 1) { max_sum += diff[i]; }
cout << (x[m - 1] - x[0]) - max_sum << endl;
}
return 0;
}
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s983818732 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | import sys
n,m=input().split()
N = int(n)
M = int(m)
X = input().split()
#MはXの要素の数
X = [int(x) for x in X]
X.sort()
if M == 1:
print(0)
sys.exit()
elif M < 1:
sys.exit()
minus = [X[i]-X[i-1] for i in range(1,M)]
#print(minus)
minus.sort()
#print(minus)
sum_num = 0
if N < M:
for i in range(N+1):
sum_num += minus[i]
print(sum_num)
elif N >= M:
print(0): | Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s404179597 | Wrong Answer | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | I = lambda: map(int, input().split())
N, M = I()
X = sorted(I())
print(sum(sorted(X[i + 1] - X[i] for i in range(M - 1))[: M - N]))
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s836356920 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | debug = 0
"""
N: state num
M: city num
"""
if debug:
N = 2
m = 10
else:
(N, M) = list(map(int, input().split()))
if debug:
p_y_list = [
[1, 30],
[1, 20],
[1, 10],
[1, 3],
[2, 63],
[2, 33],
[2, 23],
[3, 21],
[3, 7],
]
city_id_list = []
for num, z in enumerate(range(M)):
# for num, (P, Y) in enumerate(p_y_list):
if not debug:
(P, Y) = list(map(int, input().split()))
city_id_list.append([Y, P, num])
city_id_list = sorted(city_id_list, key=lambda x: x[0])
state_cnt = {}
tmp_list = []
for Y, P, num in city_id_list:
if P not in state_cnt.keys():
state_cnt[P] = 1
elif P in state_cnt.keys():
state_cnt[P] += 1
tmp_id = str(P).zfill(6) + str(state_cnt[P]).zfill(6)
tmp_list.append([num, tmp_id])
for cid in sorted(tmp_list, key=lambda x: x[0]):
print(cid[1])
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s848996036 | Accepted | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | n, m = map(int, input().split())
xs = list(map(int, input().split()))
ls = []
before = 1000000
for x in sorted(xs):
if before != 1000000:
ls.append(abs(x - before))
before = x
ls2 = sorted(ls, reverse=True)
print(sum(ls2[n - 1 :]))
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s700967878 | Wrong Answer | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | a, b = map(int, input().split())
c = [int(i) for i in input().split()]
c.sort()
for i in range(b - 1):
c[-i - 1] = c[-i - 1] - c[-i - 2]
c[0] = 0
c.sort()
print([sum(c[: -a + 1]), 0][a >= b])
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s514851262 | Accepted | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | # -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
# from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache
#############
# Constants #
#############
MOD = 10**9 + 7
INF = float("inf")
#############
# Functions #
#############
######INPUT######
def I():
return int(input().strip())
def S():
return input().strip()
def IL():
return list(map(int, input().split()))
def SL():
return list(map(str, input().split()))
def ILs(n):
return list(int(input()) for _ in range(n))
def SLs(n):
return list(input().strip() for _ in range(n))
def ILL(n):
return [list(map(int, input().split())) for _ in range(n)]
def SLL(n):
return [list(map(str, input().split())) for _ in range(n)]
######OUTPUT######
def P(arg):
print(arg)
return
def Y():
print("Yes")
return
def N():
print("No")
return
def E():
exit()
def PE(arg):
print(arg)
exit()
def YE():
print("Yes")
exit()
def NE():
print("No")
exit()
#####Shorten#####
def DD(arg):
return defaultdict(arg)
#####Inverse#####
def inv(n):
return pow(n, MOD - 2, MOD)
######Combination######
kaijo_memo = []
def kaijo(n):
if len(kaijo_memo) > n:
return kaijo_memo[n]
if len(kaijo_memo) == 0:
kaijo_memo.append(1)
while len(kaijo_memo) <= n:
kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
return kaijo_memo[n]
gyaku_kaijo_memo = []
def gyaku_kaijo(n):
if len(gyaku_kaijo_memo) > n:
return gyaku_kaijo_memo[n]
if len(gyaku_kaijo_memo) == 0:
gyaku_kaijo_memo.append(1)
while len(gyaku_kaijo_memo) <= n:
gyaku_kaijo_memo.append(
gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD
)
return gyaku_kaijo_memo[n]
def nCr(n, r):
if n == r:
return 1
if n < r or r < 0:
return 0
ret = 1
ret = ret * kaijo(n) % MOD
ret = ret * gyaku_kaijo(r) % MOD
ret = ret * gyaku_kaijo(n - r) % MOD
return ret
######Factorization######
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-(n**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
arr.append([i, cnt])
if temp != 1:
arr.append([temp, 1])
if arr == []:
arr.append([n, 1])
return arr
#####MakeDivisors######
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
return divisors
#####GCD#####
def gcd(a, b):
while b:
a, b = b, a % b
return a
#####LCM#####
def lcm(a, b):
return a * b // gcd(a, b)
#####BitCount#####
def count_bit(n):
count = 0
while n:
n &= n - 1
count += 1
return count
#####ChangeBase#####
def base_10_to_n(X, n):
if X // n:
return base_10_to_n(X // n, n) + [X % n]
return [X % n]
def base_n_to_10(X, n):
return sum(int(str(X)[-i]) * n**i for i in range(len(str(X))))
#####IntLog#####
def int_log(n, a):
count = 0
while n >= a:
n = n // a
count += 1
if a**count == n:
return count
else:
return count + 1
#############
# Main Code #
#############
N, M = IL()
X = IL()
X.sort()
D = []
for i in range(M - 1):
D.append(X[i + 1] - X[i])
D.sort()
if N >= M:
PE(0)
P(sum(D[: M - N]))
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s236788810 | Accepted | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | from sys import stdin
############################################
# from sys import stdin
import numpy as np
# read data for n sequences.
input = stdin.readline().split()
m = int(input[0])
n = int(input[1])
# n = int(stdin.readline().split()[1])
data = np.zeros(n)
d = stdin.readline().split()
for i, x in enumerate(d):
data[i] = int(x)
data = sorted(data)
dif = np.zeros(len(data) - 1)
for x in range(0, len(data) - 1):
dif[x] = data[x + 1] - data[x]
out = 0
# split in m data.
# print(data)
dif = np.zeros(len(data) - 1)
for x in range(0, len(data) - 1):
dif[x] = data[x + 1] - data[x]
out = sum(sorted(dif, reverse=True)[m - 1 :])
print(int(out))
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s732744778 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | N, M = map(int, input().split())
X_lines = str(input())
X_lines = X_lines.split()
X = []
for i in range(len(X_lines)):
X.append(int(X_lines[i]))
X_arrays = X
X_arrays.sort()
X_max = X_arrays[len(X_arrays) - 1]
X_min = X_arrays[0]
X_kyokai = [X_min]
if not N == 1:
for i in range(N - 1):
X_kyokai.append((i + 1 / N) * (X_max + X_min))
X_kyokai.append(X_max)
X_all_lines = [[]]
if not len(X_kyokai) - 2 == 0:
for i in range(len(X_kyokai) - 2):
X_all_lines.append([])
for i in range(len(X_kyokai) - 1):
for j in range(M):
if X_kyokai[i] <= X_arrays[j] and X_arrays[j] < X_kyokai[i + 1]:
X_all_lines[i].append(X_arrays[j])
X_all_lines[len(X_kyokai) - 2].append(X_max)
sum_dif = 0
for i in range(len(X_all_lines)):
i_max = X_all_lines[i][len(X_all_lines[i]) - 1]
i_min = X_all_lines[i][0]
dif = i_max - i_min
sum_dif = sum_dif + dif
print(sum_dif)
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s044963202 | Wrong Answer | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | N, M = [int(s) for s in input().split()]
ls = [int(s) for s in input().split()]
ls.sort()
d = [ls[i + 1] - ls[i] for i in range(M - 1)]
d.sort()
for _ in range(N):
if len(d) == 0:
break
del d[0]
print(sum(d))
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s513943234 | Accepted | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | # coding: utf-8
import sys
# import bisect
# import math
# import numpy as np
"""Template"""
class IP:
"""
入力を取得するクラス
"""
def __init__(self):
self.input = sys.stdin.readline
def I(self):
"""
1文字の取得に使います
:return: int
"""
return int(self.input())
def S(self):
"""
1文字の取得(str
:return: str
"""
return self.input()
def IL(self):
"""
1行を空白で区切りリストにします(int
:return: リスト
"""
return list(map(int, self.input().split()))
def SL(self):
"""
1行の文字列を空白区切りでリストにします
:return: リスト
"""
return list(map(str, self.input().split()))
def ILS(self, n):
"""
1列丸々取得します(int
:param n: 行数
:return: リスト
"""
return [int(self.input()) for _ in range(n)]
def SLS(self, n):
"""
1列丸々取得します(str
:param n: 行数
:return: リスト
"""
return [self.input() for _ in range(n)]
def SILS(self, n):
"""
Some Int LineS
横に複数、縦にも複数
:param n: 行数
:return: list
"""
return [self.IL() for _ in range(n)]
def SSLS(self, n):
"""
Some String LineS
:param n: 行数
:return: list
"""
return [self.SL() for _ in range(n)]
class Idea:
def __init__(self):
pass
def HF(self, p):
"""
Half enumeration
半分全列挙です
pの要素の和の組み合わせを作ります。
ソート、重複削除行います
:param p: list : 元となるリスト
:return: list : 組み合わせられた和のリスト
"""
return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))
def Bfs2(self, a):
"""
bit_full_search2
bit全探索の改良版
全探索させたら2進数のリストと10進数のリストを返す
:return: list2つ : 1個目 2進数(16桁) 2個目 10進数
"""
# 参考
# https://blog.rossywhite.com/2018/08/06/bit-search/
# https://atcoder.jp/contests/abc105/submissions/4088632
value = []
for i in range(1 << len(a)):
output = []
for j in range(len(a)):
if self.bit_o(i, j):
"""右からj+1番目のiが1かどうか判定"""
# output.append(a[j])
output.append(a[j])
value.append([format(i, "b").zfill(16), sum(output)])
value.sort(key=lambda x: x[1])
bin = [value[k][0] for k in range(len(value))]
val = [value[k][1] for k in range(len(value))]
return bin, val
def S(self, s, r=0, m=-1):
"""
ソート関係行います。色々な設定あります。
:param s: 元となるリスト
:param r: reversするかどうか 0=False 1=True
:param m: (2次元配列)何番目のインデックスのソートなのか
:return: None
"""
r = bool(r)
if m == -1:
s.sort(reverse=r)
else:
s.sort(reverse=r, key=lambda x: x[m])
def bit_n(self, a, b):
"""
bit探索で使います。0以上のときにTrue出します
自然数だからn
:param a: int
:param b: int
:return: bool
"""
return bool((a >> b & 1) > 0)
def bit_o(self, a, b):
"""
bit探索で使います。1のときにTrue出すよ
oneで1
:param a: int
:param b: int
:return: bool
"""
return bool(((a >> b) & 1) == 1)
def ceil(self, x, y):
"""
Round up
小数点切り上げ割り算
:param x: int
:param y: int
:return: int
"""
return -(-x // y)
def ave(self, a):
"""
平均を求めます
:param a: list
:return: int
"""
return sum(a) / len(a)
"""ここからメインコード"""
def main():
# 1文字に省略
r, e = range, enumerate
ip = IP()
id = Idea()
"""この下から書いてね"""
n, m = ip.IL()
x = ip.IL()
id.S(x)
s = []
for i in r(0, m - 1):
s.append(x[i + 1] - x[i])
id.S(s, 1)
if m == 1:
print(0)
elif len(s) >= m:
print(0)
else:
for _ in r(n - 1):
s.pop(0)
if len(s) == 0:
break
print(sum(s))
main()
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s167446299 | Runtime Error | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | # coding: utf-8
# Your code here!
import bisect
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
a = x[len(x) - 1] - x[0]
cnt = [0]
d = 0
d1 = 0
mini = 100000000
if m <= n:
print(0)
elif n == 1:
print(a)
else:
if n == 2:
for i in range(m - 1):
d = abs(x[i] - x[0])
d1 = abs(x[len(x) - 1] - x[i + 1])
if d + d1 < mini:
mini = d + d1
print(mini)
else:
i = 0
a = 0
ae = 0
while i < n // 2:
a = x[0]
ae = x[len(x) - 1]
x.remove(x[0])
x.remove(x[len(x) - 1])
i += 1
if n % 2 == 1:
print(x[len(x) - 1] - x[0])
else:
for i in range(m - 1):
d = abs(x[i] - a)
d1 = abs(ae - x[i + 1])
if d + d1 < mini:
mini = d + d1
print(mini)
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
Find the minimum number of moves required to achieve the objective.
* * * | s816518567 | Wrong Answer | p03137 | Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M | nm = [int(x) for x in input().split()]
x = [int(y) for y in input().split()]
margin = []
sort_x = sorted(x)
for p in range(nm[1] - 1):
margin.append(sort_x[p + 1] - sort_x[p])
sort_mar = sorted(margin)
print(sum(sort_mar[: nm[1] - nm[0]]))
| Statement
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
these pieces, by repeating the following move:
**Move** : Choose a piece and let x be its coordinate. Put that piece at
coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already
regarded as visited.
Find the minimum number of moves required to achieve the objective. | [{"input": "2 5\n 10 12 1 2 14", "output": "5\n \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum number of moves required.\n\n * Initially, put the two pieces at coordinates 1 and 10.\n * Move the piece at coordinate 1 to 2.\n * Move the piece at coordinate 10 to 11.\n * Move the piece at coordinate 11 to 12.\n * Move the piece at coordinate 12 to 13.\n * Move the piece at coordinate 13 to 14.\n\n* * *"}, {"input": "3 7\n -10 -3 0 9 -100 2 17", "output": "19\n \n\n* * *"}, {"input": "100 1\n -100000", "output": "0"}] |
If Takahashi will win, print `Takahashi`; if Aoki will win, print `Aoki`.
* * * | s126927278 | Runtime Error | p03422 | Input is given from Standard Input in the following format:
N
A_1 K_1
:
A_N K_N | from math import ceil
def grundy(a, k):
if a < k:
return 0
d, m = divmod(a, k)
if m == 0:
return d
d1 = d + 1
if d > k:
return grundy(a - d1, k)
e = ceil(m / d1) * d1
return grundy(a - e, k)
n = int(input())
nim = 0
for _ in range(n):
a, k = map(int, input().split())
nim ^= grundy(a, k)
print("Takahashi" if nim > 0 else "Aoki")
| Statement
Takahashi and Aoki are playing a stone-taking game. Initially, there are N
piles of stones, and the i-th pile contains A_i stones and has an associated
integer K_i.
Starting from Takahashi, Takahashi and Aoki take alternate turns to perform
the following operation:
* Choose a pile. If the i-th pile is selected and there are X stones left in the pile, remove some number of stones between 1 and floor(X/K_i) (inclusive) from the pile.
The player who first becomes unable to perform the operation loses the game.
Assuming that both players play optimally, determine the winner of the game.
Here, floor(x) represents the largest integer not greater than x. | [{"input": "2\n 5 2\n 3 3", "output": "Aoki\n \n\nInitially, from the first pile at most floor(5/2)=2 stones can be removed at a\ntime, and from the second pile at most floor(3/3)=1 stone can be removed at a\ntime.\n\n * If Takahashi first takes two stones from the first pile, from the first pile at most floor(3/2)=1 stone can now be removed at a time, and from the second pile at most floor(3/3)=1 stone can be removed at a time.\n * Then, if Aoki takes one stone from the second pile, from the first pile at most floor(3/2)=1 stone can be removed at a time, and from the second pile no more stones can be removed (since floor(2/3)=0).\n * Then, if Takahashi takes one stone from the first pile, from the first pile at most floor(2/2)=1 stone can now be removed at a time, and from the second pile no more stones can be removed.\n * Then, if Aoki takes one stone from the first pile, from the first pile at most floor(1/2)=0 stones can now be removed at a time, and from the second pile no more stones can be removed.\n\nNo more operation can be performed, thus Aoki wins. If Takahashi plays\ndifferently, Aoki can also win by play accordingly.\n\n* * *"}, {"input": "3\n 3 2\n 4 3\n 5 1", "output": "Takahashi\n \n\n* * *"}, {"input": "3\n 28 3\n 16 4\n 19 2", "output": "Aoki\n \n\n* * *"}, {"input": "4\n 3141 59\n 26535 897\n 93 23\n 8462 64", "output": "Takahashi"}] |
Print the number of inns from which you can see the ocean.
* * * | s830749519 | Runtime Error | p03072 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | n = int(input())
li = [int(i) for i in input().split()]
count = 0
if li[0] < li[1]:
p = [x for x in li if x >= li[0] and x >= li[1]]
print(len(p) + 1)
else:
p = [x for x in li if x >= li[0] and x >= li[1]]
print(len(p))
| Statement
There are N mountains ranging from east to west, and an ocean to the west.
At the top of each mountain, there is an inn. You have decided to choose where
to stay from these inns.
The height of the i-th mountain from the west is H_i.
You can certainly see the ocean from the inn at the top of the westmost
mountain.
For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N),
you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and
H_{i-1} \leq H_i.
From how many of these N inns can you see the ocean? | [{"input": "4\n 6 5 6 8", "output": "3\n \n\nYou can see the ocean from the first, third and fourth inns from the west.\n\n* * *"}, {"input": "5\n 4 5 3 5 4", "output": "3\n \n\n* * *"}, {"input": "5\n 9 5 6 8 4", "output": "1"}] |
Print the number of inns from which you can see the ocean.
* * * | s733807876 | Accepted | p03072 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | import sys
def CheckRangeInt(input_str, _min, _max):
if input_str.isdecimal() == 0 or int(input_str) < _min or int(input_str) > _max:
print("error")
sys.exit()
return int(input_str)
def CheckRangeList(input_list, _min, _max):
for i in range(len(input_list)):
if H[i] < _min or H[i] > _max:
print("error")
sys.exit()
return input_list
N = input()
# if N.isdecimal()==0 or int(N)<1 or int(N)>20:
# print("error")
# sys.exit()
# N=int(N)
N = CheckRangeInt(N, 1, 20)
H = list(map(int, input().strip().split()))
if len(H) != N:
print("error")
sys.exit()
# for i in range(N) :
# if H[i]<1 or H[i]>100 :
# print("error")
# sys.exit()
H = CheckRangeList(H, 1, 100)
highest = 0
can_see = 0
for i in range(N):
if H[i] >= highest:
can_see = can_see + 1
highest = H[i]
print(can_see)
| Statement
There are N mountains ranging from east to west, and an ocean to the west.
At the top of each mountain, there is an inn. You have decided to choose where
to stay from these inns.
The height of the i-th mountain from the west is H_i.
You can certainly see the ocean from the inn at the top of the westmost
mountain.
For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N),
you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and
H_{i-1} \leq H_i.
From how many of these N inns can you see the ocean? | [{"input": "4\n 6 5 6 8", "output": "3\n \n\nYou can see the ocean from the first, third and fourth inns from the west.\n\n* * *"}, {"input": "5\n 4 5 3 5 4", "output": "3\n \n\n* * *"}, {"input": "5\n 9 5 6 8 4", "output": "1"}] |
Print the number of inns from which you can see the ocean.
* * * | s007132359 | Accepted | p03072 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | lista = []
contador = 0
entrou = 0
nVezes = int(input())
linha = input()
lista = linha.split()
for aux in range(len(lista)):
for aux2 in range(aux, -1, -1):
if int(lista[aux]) < int(lista[aux2]):
entrou = 1
if entrou == 0:
contador += 1
entrou = 0
print(contador)
| Statement
There are N mountains ranging from east to west, and an ocean to the west.
At the top of each mountain, there is an inn. You have decided to choose where
to stay from these inns.
The height of the i-th mountain from the west is H_i.
You can certainly see the ocean from the inn at the top of the westmost
mountain.
For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N),
you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and
H_{i-1} \leq H_i.
From how many of these N inns can you see the ocean? | [{"input": "4\n 6 5 6 8", "output": "3\n \n\nYou can see the ocean from the first, third and fourth inns from the west.\n\n* * *"}, {"input": "5\n 4 5 3 5 4", "output": "3\n \n\n* * *"}, {"input": "5\n 9 5 6 8 4", "output": "1"}] |
Print the number of inns from which you can see the ocean.
* * * | s449559969 | Wrong Answer | p03072 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | k = int(input())
numerosSTR = input().split(" ")
numeros = []
contador = 0
teste = [6, 5, 6, 8]
for i in numerosSTR:
numeros.append(int(i))
for j in numeros:
if j <= numeros[-1]:
contador += 1
if numeros != teste:
print(contador)
else:
print(contador - 1)
| Statement
There are N mountains ranging from east to west, and an ocean to the west.
At the top of each mountain, there is an inn. You have decided to choose where
to stay from these inns.
The height of the i-th mountain from the west is H_i.
You can certainly see the ocean from the inn at the top of the westmost
mountain.
For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N),
you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and
H_{i-1} \leq H_i.
From how many of these N inns can you see the ocean? | [{"input": "4\n 6 5 6 8", "output": "3\n \n\nYou can see the ocean from the first, third and fourth inns from the west.\n\n* * *"}, {"input": "5\n 4 5 3 5 4", "output": "3\n \n\n* * *"}, {"input": "5\n 9 5 6 8 4", "output": "1"}] |
Print the number of inns from which you can see the ocean.
* * * | s627213946 | Accepted | p03072 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | n = int(input())
a = input().split()
for j in range(n):
a[j] = int(a[j])
m = []
m.append(a[0])
for k in range(n - 1):
x = max(m)
if x <= a[k + 1]:
m.append(a[k + 1])
print(len(m))
| Statement
There are N mountains ranging from east to west, and an ocean to the west.
At the top of each mountain, there is an inn. You have decided to choose where
to stay from these inns.
The height of the i-th mountain from the west is H_i.
You can certainly see the ocean from the inn at the top of the westmost
mountain.
For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N),
you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and
H_{i-1} \leq H_i.
From how many of these N inns can you see the ocean? | [{"input": "4\n 6 5 6 8", "output": "3\n \n\nYou can see the ocean from the first, third and fourth inns from the west.\n\n* * *"}, {"input": "5\n 4 5 3 5 4", "output": "3\n \n\n* * *"}, {"input": "5\n 9 5 6 8 4", "output": "1"}] |
Print the number of inns from which you can see the ocean.
* * * | s752028616 | Wrong Answer | p03072 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | N = input()
list = [int(i) for i in input().split()]
replace = [0 if i < list[0] else i for i in list]
print(len([i for i in replace if i > 0]))
| Statement
There are N mountains ranging from east to west, and an ocean to the west.
At the top of each mountain, there is an inn. You have decided to choose where
to stay from these inns.
The height of the i-th mountain from the west is H_i.
You can certainly see the ocean from the inn at the top of the westmost
mountain.
For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N),
you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and
H_{i-1} \leq H_i.
From how many of these N inns can you see the ocean? | [{"input": "4\n 6 5 6 8", "output": "3\n \n\nYou can see the ocean from the first, third and fourth inns from the west.\n\n* * *"}, {"input": "5\n 4 5 3 5 4", "output": "3\n \n\n* * *"}, {"input": "5\n 9 5 6 8 4", "output": "1"}] |
Print the number of inns from which you can see the ocean.
* * * | s861750482 | Runtime Error | p03072 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | input()
H = map(int, input().spkit())
a = [next(H)]
a.extend(h for h in H if a[-1] <= h)
print(len(a))
| Statement
There are N mountains ranging from east to west, and an ocean to the west.
At the top of each mountain, there is an inn. You have decided to choose where
to stay from these inns.
The height of the i-th mountain from the west is H_i.
You can certainly see the ocean from the inn at the top of the westmost
mountain.
For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N),
you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and
H_{i-1} \leq H_i.
From how many of these N inns can you see the ocean? | [{"input": "4\n 6 5 6 8", "output": "3\n \n\nYou can see the ocean from the first, third and fourth inns from the west.\n\n* * *"}, {"input": "5\n 4 5 3 5 4", "output": "3\n \n\n* * *"}, {"input": "5\n 9 5 6 8 4", "output": "1"}] |
Print the number of inns from which you can see the ocean.
* * * | s840056321 | Accepted | p03072 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | import sys
inp = [i.strip() for i in sys.stdin.readlines()]
if len(inp) == 1:
if len(inp[0].split()) == 2:
A, B = map(int, inp[0].split())
print(max(2 * A - 1, 2 * B - 1, A + B))
else:
S = inp[0]
N = len(S)
X = ""
Y = ""
for i in range(N):
if i % 2 == 0:
X = X + "0"
Y = Y + "1"
else:
X = X + "1"
Y = Y + "0"
A = 0
B = 0
for i in range(N):
if X[i] != S[i]:
A += 1
if Y[i] != S[i]:
B += 1
print(min(A, B))
else:
if len(inp[0].split()) == 1:
N = int(inp[0])
H = [int(i) for i in inp[1].split()]
ans = 1
for i in range(1, N):
flag = 1
for j in range(i):
if H[j] > H[i]:
flag = 0
break
if flag == 1:
ans += 1
print(ans)
else:
N, K = map(int, inp[0].split())
S = inp[1]
L = [0]
tmp = "1"
for i in range(N):
if tmp != S[i]:
L.append(1)
else:
L[-1] += 1
tmp = S[i]
if tmp == "0":
L.append(0)
M = len(L)
if M <= 2 * K + 1:
print(N)
exit()
X = [0 for i in range(M + 1)]
for i in range(M):
X[i + 1] = L[i] + X[i]
ans = 0
for i in range(0, M - 2 * K, 2):
ans = max(ans, X[i + 2 * K + 1] - X[i])
print(ans)
| Statement
There are N mountains ranging from east to west, and an ocean to the west.
At the top of each mountain, there is an inn. You have decided to choose where
to stay from these inns.
The height of the i-th mountain from the west is H_i.
You can certainly see the ocean from the inn at the top of the westmost
mountain.
For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N),
you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and
H_{i-1} \leq H_i.
From how many of these N inns can you see the ocean? | [{"input": "4\n 6 5 6 8", "output": "3\n \n\nYou can see the ocean from the first, third and fourth inns from the west.\n\n* * *"}, {"input": "5\n 4 5 3 5 4", "output": "3\n \n\n* * *"}, {"input": "5\n 9 5 6 8 4", "output": "1"}] |
Print the number of inns from which you can see the ocean.
* * * | s019325243 | Accepted | p03072 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | icase = 0
if icase == 0:
n = int(input())
h = list(map(int, input().split()))
hh = h[0]
icnt = 1
for i in range(1, n):
if hh <= h[i]:
icnt += 1
hh = max(hh, h[i])
print(icnt)
| Statement
There are N mountains ranging from east to west, and an ocean to the west.
At the top of each mountain, there is an inn. You have decided to choose where
to stay from these inns.
The height of the i-th mountain from the west is H_i.
You can certainly see the ocean from the inn at the top of the westmost
mountain.
For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N),
you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and
H_{i-1} \leq H_i.
From how many of these N inns can you see the ocean? | [{"input": "4\n 6 5 6 8", "output": "3\n \n\nYou can see the ocean from the first, third and fourth inns from the west.\n\n* * *"}, {"input": "5\n 4 5 3 5 4", "output": "3\n \n\n* * *"}, {"input": "5\n 9 5 6 8 4", "output": "1"}] |
Print the number of inns from which you can see the ocean.
* * * | s018676588 | Accepted | p03072 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | line = input()
line = input()
numbers = [int(n) for n in line.split()]
predicted_value = 0
for i in range(len(numbers)):
is_smaller = False
for k in range(i):
if numbers[i] < numbers[k]:
is_smaller = True
break
if not is_smaller:
predicted_value += 1
print(predicted_value)
| Statement
There are N mountains ranging from east to west, and an ocean to the west.
At the top of each mountain, there is an inn. You have decided to choose where
to stay from these inns.
The height of the i-th mountain from the west is H_i.
You can certainly see the ocean from the inn at the top of the westmost
mountain.
For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N),
you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and
H_{i-1} \leq H_i.
From how many of these N inns can you see the ocean? | [{"input": "4\n 6 5 6 8", "output": "3\n \n\nYou can see the ocean from the first, third and fourth inns from the west.\n\n* * *"}, {"input": "5\n 4 5 3 5 4", "output": "3\n \n\n* * *"}, {"input": "5\n 9 5 6 8 4", "output": "1"}] |
Print the number of inns from which you can see the ocean.
* * * | s272617490 | Accepted | p03072 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | x = input()
y = list(map(int, input().split()))
max_ = y[0]
point = 0
for i in y:
if i >= max_:
point += 1
max_ = i
print(point)
| Statement
There are N mountains ranging from east to west, and an ocean to the west.
At the top of each mountain, there is an inn. You have decided to choose where
to stay from these inns.
The height of the i-th mountain from the west is H_i.
You can certainly see the ocean from the inn at the top of the westmost
mountain.
For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N),
you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and
H_{i-1} \leq H_i.
From how many of these N inns can you see the ocean? | [{"input": "4\n 6 5 6 8", "output": "3\n \n\nYou can see the ocean from the first, third and fourth inns from the west.\n\n* * *"}, {"input": "5\n 4 5 3 5 4", "output": "3\n \n\n* * *"}, {"input": "5\n 9 5 6 8 4", "output": "1"}] |
Print the number of inns from which you can see the ocean.
* * * | s983818614 | Accepted | p03072 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | n = int(input())
H = map(int, input().split())
k = 0
j = 0
for num in H:
if num >= k:
j = j + 1
k = num
print(j)
| Statement
There are N mountains ranging from east to west, and an ocean to the west.
At the top of each mountain, there is an inn. You have decided to choose where
to stay from these inns.
The height of the i-th mountain from the west is H_i.
You can certainly see the ocean from the inn at the top of the westmost
mountain.
For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N),
you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and
H_{i-1} \leq H_i.
From how many of these N inns can you see the ocean? | [{"input": "4\n 6 5 6 8", "output": "3\n \n\nYou can see the ocean from the first, third and fourth inns from the west.\n\n* * *"}, {"input": "5\n 4 5 3 5 4", "output": "3\n \n\n* * *"}, {"input": "5\n 9 5 6 8 4", "output": "1"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s957791149 | Accepted | p02399 | Two integers a and b are given in a line. | val = input().split()
val = [int(n) for n in val]
d = val[0] // val[1]
r = val[0] % val[1]
f = val[0] / val[1]
print(d, r, "{:.10f}".format(f))
| A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s020257159 | Wrong Answer | p02399 | Two integers a and b are given in a line. | lis = [int(x) for x in input().split()]
print(lis[0] // lis[1], end=" ")
print(lis[0] % lis[1], end=" ")
print(lis[0] / lis[1])
| A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s053897562 | Wrong Answer | p02399 | Two integers a and b are given in a line. | tmp = input().split()
value = [0 for _ in range(2)]
value[0] = int(tmp[0])
value[1] = int(tmp[1])
d = value[0] / value[1]
r = value[0] % value[1]
f = value[0] / value[1]
print(str(int(d)) + " " + str(r) + " " + str(float(f)))
| A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s955379752 | Accepted | p02399 | Two integers a and b are given in a line. | p = [int(i) for i in input().split()]
print("{} {} {:f}".format(p[0] // p[1], p[0] % p[1], p[0] / p[1]))
| A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s231536097 | Accepted | p02399 | Two integers a and b are given in a line. | list = input().split()
if (
1 <= int(list[0])
and int(list[0]) <= 10000000000
and 1 <= int(list[1])
and int(list[1]) <= 10000000000
):
d = int(list[0]) / int(list[1])
r = int(list[0]) - int(list[1]) * int(d)
print("{0} {1} {2:.5f}".format(int(d), r, d))
else:
print("ERROR")
| A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s908476139 | Accepted | p02399 | Two integers a and b are given in a line. | l = list(map(int, input().split()))
m = l[0] // l[1]
n = l[0] % l[1]
o = "{:.5f}".format(l[0] / l[1])
print(str(m) + " " + str(n) + " " + str(o))
| A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s385015801 | Accepted | p02399 | Two integers a and b are given in a line. | v = list(map(int, input().split()))
print(int(v[0] / v[1]), v[0] % v[1], "{:f}".format(float(v[0] / v[1])))
| A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s227545443 | Accepted | p02399 | Two integers a and b are given in a line. | a, b = list(map(int, input().strip().split()))
print(f"{int(a//b)} {int(a%b)} {float(a/b):.5f}")
| A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s123482653 | Accepted | p02399 | Two integers a and b are given in a line. | hoge = list(map(int, input().split()))
a, b = hoge[0], hoge[1]
print("{0} {1} {2:.12f}".format(a // b, a % b, a / b))
| A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s050367073 | Wrong Answer | p02399 | Two integers a and b are given in a line. | k = input().split()
a = int(k[0])
b = int(k[1])
print(str(a // b) + " " + str(a % b) + " " + "{:.5}".format(a / b))
| A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s206539187 | Wrong Answer | p02399 | Two integers a and b are given in a line. | a,b=map(int,input().split())
print(a//b,a%b,a/b,sep=' ') | A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s936943567 | Wrong Answer | p02399 | Two integers a and b are given in a line. | x, y = [int(i) for i in input().split()]
print("{0} {1} {2}".format(x // y, x % y, x / y))
| A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s466023361 | Accepted | p02399 | Two integers a and b are given in a line. | i = input().split()
n1 = int(i[0])
n2 = int(i[1])
d = str(n1 // n2)
e = str(n1 % n2)
f = str(format(n1 / n2, ".5f"))
print(d + " " + e + " " + f)
| A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s475159723 | Wrong Answer | p02399 | Two integers a and b are given in a line. | numbers = [int(x) for x in input().split(" ")]
a, b = numbers[0], numbers[1]
print("{} {} {}".format((a // b), (a % b), (a / b)))
| A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Print d, r and f separated by a space in a line. For f, the output should not
contain an absolute error greater than 10-5. | s488139011 | Wrong Answer | p02399 | Two integers a and b are given in a line. | c = input()
a, b = c.split()
print("{} {} {}".format(int(int(a) / int(b)), int(a) % int(b), int(a) / int(b)))
| A/B Problem
Write a program which reads two integers a and b, and calculates the following
values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number) | [{"input": "3 2", "output": "1 1 1.50000"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s917409398 | Accepted | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input():
return int(input())
def i_map():
return map(int, input().split())
def i_list():
return list(i_map())
def i_row(N):
return [i_input() for _ in range(N)]
def i_row_list(N):
return [i_list() for _ in range(N)]
def s_input():
return input()
def s_map():
return input().split()
def s_list():
return list(s_map())
def s_row(N):
return [s_input for _ in range(N)]
def s_row_str(N):
return [s_list() for _ in range(N)]
def s_row_list(N):
return [list(s_input()) for _ in range(N)]
def lcm(a, b):
return a * b // gcd(a, b)
sys.setrecursionlimit(10**6)
INF = float("inf")
MOD = 10**9 + 7
num_list = []
str_list = []
def main():
n, a, b = i_list()
ss = s_input()
kakuteisha = 0
b_juni = 0
for i in range(len(ss)):
s = ss[i]
if s == "a":
if kakuteisha < a + b:
kakuteisha += 1
print("Yes")
else:
print("No")
elif s == "b":
if kakuteisha < a + b and b_juni + 1 <= b:
kakuteisha += 1
b_juni += 1
print("Yes")
else:
print("No")
else:
print("No")
if __name__ == "__main__":
main()
| Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s430749050 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | # input 参加人数n, 予選通過人数a, 予選通過人数b
n, a, b = map(int, input().split())
# input 参加者情報s
s = input().split()
counter = 0
count_b = 0
for i in s:
counter += 1
# cの場合はNo
if i == "c":
print("No")
# aの場合、counter <= A+BであればYes
if counter < (a+b):
print("Yes")
else:
print("No")
# bの場合、counter <= A+B かつ count_b < B であれば"Yes"
if counter < (a+b) && count_b < b:
print("Yes")
count_b += 1
else:
print("No")
| Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s835199905 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | #include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i++)
typedef long long ll;
using namespace std;
int main()
{
int n, a, b;
cin >> n >> a >> b;
int total = a + b;
string s; cin >> s;
int cnt = 0, cntb = 0;
rep(i,n){
string ans = "Yes";
if (s[i] == 'c') {
ans = "No";
}
else if (s[i] == 'a')
{
if (cnt < a+b) cnt++;
else ans = "No";
}
else {
cntb++;
if (cnt < a+b and cntb <= b) cnt++;
else ans = "No";
}
cout << ans << endl;
}
} | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s942591766 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | 5 2 2
ccccc | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s750976530 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | n, A, B = map(int, input().split())
a, b = 0
s = input()
for i in range(n):
s_i = s[i]
if s_i == 'a':
if (a + b) < (A + B):
a += 1
print('Yes')
else:
print('No')
elif s_i == 'b':
if ((a + b) < (A + B)) & (b < B):
b += 1
print('Yes')
else:
print('No')
else:
print('No')
| Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s765274585 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | N, A, B = map(int, input().split())
S = input()
ok_count = 0
ok_fcount = 0
for s in S:
if s == a:
if ok_count < A+B-1
print('Yes')
ok_count +=1
else:
print('No')
elif s == b:
if ok_count <= A+B-1 and ok_fcount < B-1:
print('Yes')
ok_count+=1
ok_fcount+=1
else:
print('No')
else:
print('No')
| Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s810698451 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | N, A, B = map(int, input().split())
S = list(input().split)
ok_count = 0
ok_fcount = 0
for s in S:
if s == a:
if ok_count < A+B-1
print('Yes')
ok_count +=1
else:
print('No')
elif s == b:
if ok_count <= A+B-1 and ok_fcount < B-1:
print('Yes')
ok_count+=1
ok_fcount+=1
else:
print('No')
else:
print('No') | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s891718196 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | N, A, B = map(int, input().split())
S = input()
ok_count = 0
ok_fcount = 0
for i in range(N):
if S[i] == 'a':
if ok_count < A+B-1
print('Yes')
ok_count +=1
else:
print('No')
elif S[i] == 'b':
if ok_count <= A+B-1 and ok_fcount < B-1:
print('Yes')
ok_count+=1
ok_fcount+=1
else:
print('No')
else:
print('No') | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s181631843 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | def resolve():
N, A, B = list(map(int, input().split()))
S = str(input())
num = 0
foreignnum = 1
for i in range(N):
if S[i] == 'a':
if (num < A + B):
num += 1
print('Yes')
else:
print('No')
if S[i] == 'b':
if (num < A + B) and (foreignnum <= B):
num += 1
foreignnum += 1
print('Yes')
else:
print('No')
if S[i] == 'c':
print('No')
return
resolve() | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s581868409 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | #include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;
int main() {
int n, a, b;
string s;
cin >> n >> a >> b >> s;
int cnt = 0; //予選通過確定者の人数
int kaigai = 0;
rep(i, n) {
if (cnt + 1 <= a + b) {
if (s[i] == 'a') {
cnt++;
cout << "Yes" << endl;
} else if (s[i] == 'b') {
kaigai++;
if (kaigai <= b) {
cout << "Yes" << endl;
cnt++;
} else
cout << "No" << endl;
} else {
cout << "No" << endl;
}
} else
cout << "No" << endl;
}
} | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s710830408 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | n,a,b=map(int,input().split())
s=input()
all=a+b
in=b
for i in range(n):
if all==0:
print('No')
elif s[i]=='a':
print('Yes')
all-=1
elif s[i]=='b' and in>0:
print('Yes')
all-=1
in-=1
else:
print('No') | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s564197367 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | N,A,B=map(int,input().split())
S=list(map(input().split()))
sin=0
cos=0
for i in range(S)
if S.pop(i)='a'or'b':
sin+=1
if S.pop(i)='b':
cos+=1
print("Yes" if S.pop(i)='a' and sin<A+B:
"Yes" elif S.pop(i)='b' and B<=cos and sin<A+B:
else "No")
| Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s333567630 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | N,A,B = map(int,input().split())
S=input()
pas=0
kai=0
for num in S:
if num=="a":
if pas<A+B:
pas +=1
print("Yes")
else:
print("No")
elif num=="b":
if pas<A+B and :
pas +=1
| Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s737339075 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | import math
n = int(input())
x1 = math.ceil(n / 1.08)
print(":(" if math.floor(x1 * 1.08) != n else x1)
| Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s649258398 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | N,A,B=map(int,input().split())
s = input().rstrip()
count = 0
countB = 0
for i in range(N):
if A+B <= count:
print('No')
else:
if s[i] == 'a':
print('Yes')
count += 1
elif s[i] =='b'"
if countB <= B:
print('Yes')
countB += 1
count += 1
else:
print('No')
else:
print('No') | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s485424953 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | N,A,B = map(int, input().split())
S = input().split()
s=[]
for i in S:
s.append(i)
list=[]
H = list.count('b')
for i in range(N):
if s[i] == 'c'
print('No')
elif s[i] =='a' and len(list) <= A+B:
print('Yes')
list.append(a)
elif s[i] =='a':
print('No')
elif len(list) <= A+B and H <= B:
print('Yes')
else:
print('No') | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s414909762 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | n, a, b = map(int, input().split())
s = input()
all = list(s)
count = 0
count_b = 0
for i in all:
if i == 'a':
if count <= a + b:
print('yes')
count += 1
else:
print('no')
if i == 'b':
if count <= a + b and count_b <= b
print('yes')
count += 1
count_b += 1
else:
print('no')
else:
print('no') | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s198481969 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | N,A,B = map(int,input().split())
S = input()
cnt = 0
bcnt = 1
for s in S :
if s =='a' :
if A + B > cnt :
print('Yes')
cnt += 1
else :
print('No')
elif s == 'b'
if A + B > cnt and B => bcnt :
print('Yes')
bcnt += 1
cnt += 1
else :
print('No')
else :
print('No') | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s314282538 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | # coding: utf-8
N,A,B=list(map(int,input().split()))
S = input()
cnt = 1
for i in range(N):
if S[i] == "c":
print("No")
elif S[i] == "a":
if cnt < A+B:
print("Yes")
cnt +=1
else:
print("No")
elif S[i] == "b":
if cnt < B:
print("Yes")
cnt +=1
else:
print("No") | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s497784979 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | N,A,B = map(int,input().split())
S = list(input())
cnt = 0
bcnt = 1
for s in S :
if s =='a' :
if A + B > cnt :
print('Yes')
cnt += 1
else :
print('No')
elif s == 'b'
if A + B > cnt and B => bcnt :
print('Yes')
bcnt += 1
cnt += 1
else :
print('No')
else :
print('No') | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s370951560 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | N,A,B = map(int,input().split())
S = list(input())
cnt = 0
bcnt = 1
for i in S :
if S[i] == 'a' :
if A + B > cnt :
print('Yes')
cnt += 1
else :
print('No')
elif S[i] == 'b'
if A + B > cnt and B => bcnt :
print('Yes')
bcnt += 1
cnt += 1
else :
print('No')
else :
print('No')
| Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s144110919 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | # coding: utf-8
As = list(input().rstrip().split(" "))
N = int(As[0])
A = int(As[1])
B = int(As[2])
S = input()
cnt = 1
for i in range(N):
if S[i] == "c":
print("No")
elif S[i] == "a":
if cnt < A+B:
print("Yes")
cnt +=1
else:
print("No")
elif S[i] == "b":
if cnt < B:
print("Yes")
cnt +=1
else:
print("No") | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Output N lines. On the i-th line, output `Yes` if the i-th participant passed
the Qualification contests or `No` if that participant did not pass.
* * * | s392437293 | Runtime Error | p03971 | Inputs are provided from Standard Input in the following form.
N A B
S | n,x,y=map(int,input().split())
s= input()
c=0
d=x+y
f= False
for i in range(n):
if s[i]=="A":
if c<d:
f=True
elif s[i]=="B":
if c<d and c<=b:
f=True
if f:
print("YES")
c+=1
else:
print("NO")
f=False | Statement
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The
participants are either students in Japan, students from overseas, or neither
of these.
Only Japanese students or overseas students can pass the Qualification
contests. The students pass when they satisfy the conditions listed below,
from the top rank down. Participants who are not students cannot pass the
Qualification contests.
* A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.
* An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.
A string S is assigned indicating attributes of all participants. If the i-th
character of string S is `a`, this means the participant ranked i-th in the
Qualification contests is a Japanese student; `b` means the participant ranked
i-th is an overseas student; and `c` means the participant ranked i-th is
neither of these.
Write a program that outputs for all the participants in descending rank
either `Yes` if they passed the Qualification contests or `No` if they did not
pass. | [{"input": "10 2 3\n abccabaabb", "output": "Yes\n Yes\n No\n No\n Yes\n Yes\n Yes\n No\n No\n No\n \n\nThe first, second, fifth, sixth, and seventh participants pass the\nQualification contests.\n\n* * *"}, {"input": "12 5 2\n cabbabaacaba", "output": "No\n Yes\n Yes\n Yes\n Yes\n No\n Yes\n Yes\n No\n Yes\n No\n No\n \n\nThe sixth participant is third among overseas students and thus does not pass\nthe Qualification contests.\n\n* * *"}, {"input": "5 2 2\n ccccc", "output": "No\n No\n No\n No\n No"}] |
Print the length of the period in which he can start studying, as an integer.
* * * | s545984630 | Wrong Answer | p02663 | Input is given from Standard Input in the following format:
H_1 M_1 H_2 M_2 K | # list(map(int,input().split()))
a, b, c, d, e = list(map(int, input().split()))
print(max(c * 60 + d - a * 60 + b - e, 0))
| Statement
In this problem, we use the 24-hour clock.
Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the
time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study
for K consecutive minutes while he is up. What is the length of the period in
which he can start studying? | [{"input": "10 0 15 0 30", "output": "270\n \n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly\nthree in the afternoon. It takes 30 minutes to do the study, so he can start\nit in the period between ten o'clock and half-past two. The length of this\nperiod is 270 minutes, so we should print 270.\n\n* * *"}, {"input": "10 0 12 0 120", "output": "0\n \n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly\nnoon. It takes 120 minutes to do the study, so he has to start it at exactly\nten o'clock. Thus, we should print 0."}] |
Print the length of the period in which he can start studying, as an integer.
* * * | s932718307 | Accepted | p02663 | Input is given from Standard Input in the following format:
H_1 M_1 H_2 M_2 K | [HS, MS, HE, ME, T] = [int(i) for i in input().split()]
print(max(HE * 60 + ME - HS * 60 - MS - T, 0))
| Statement
In this problem, we use the 24-hour clock.
Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the
time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study
for K consecutive minutes while he is up. What is the length of the period in
which he can start studying? | [{"input": "10 0 15 0 30", "output": "270\n \n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly\nthree in the afternoon. It takes 30 minutes to do the study, so he can start\nit in the period between ten o'clock and half-past two. The length of this\nperiod is 270 minutes, so we should print 270.\n\n* * *"}, {"input": "10 0 12 0 120", "output": "0\n \n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly\nnoon. It takes 120 minutes to do the study, so he has to start it at exactly\nten o'clock. Thus, we should print 0."}] |
Print the length of the period in which he can start studying, as an integer.
* * * | s446638531 | Wrong Answer | p02663 | Input is given from Standard Input in the following format:
H_1 M_1 H_2 M_2 K | h, m, x, y, k = map(int, input().split())
mi = x * 60 + y - h * 60 + m - k
print(mi)
| Statement
In this problem, we use the 24-hour clock.
Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the
time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study
for K consecutive minutes while he is up. What is the length of the period in
which he can start studying? | [{"input": "10 0 15 0 30", "output": "270\n \n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly\nthree in the afternoon. It takes 30 minutes to do the study, so he can start\nit in the period between ten o'clock and half-past two. The length of this\nperiod is 270 minutes, so we should print 270.\n\n* * *"}, {"input": "10 0 12 0 120", "output": "0\n \n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly\nnoon. It takes 120 minutes to do the study, so he has to start it at exactly\nten o'clock. Thus, we should print 0."}] |
Print the length of the period in which he can start studying, as an integer.
* * * | s717096545 | Runtime Error | p02663 | Input is given from Standard Input in the following format:
H_1 M_1 H_2 M_2 K | t = list(map(int, input()))
one = t.count(1)
print(one * (one + 1) // 2 - 2)
| Statement
In this problem, we use the 24-hour clock.
Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the
time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study
for K consecutive minutes while he is up. What is the length of the period in
which he can start studying? | [{"input": "10 0 15 0 30", "output": "270\n \n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly\nthree in the afternoon. It takes 30 minutes to do the study, so he can start\nit in the period between ten o'clock and half-past two. The length of this\nperiod is 270 minutes, so we should print 270.\n\n* * *"}, {"input": "10 0 12 0 120", "output": "0\n \n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly\nnoon. It takes 120 minutes to do the study, so he has to start it at exactly\nten o'clock. Thus, we should print 0."}] |
Print the length of the period in which he can start studying, as an integer.
* * * | s411034066 | Wrong Answer | p02663 | Input is given from Standard Input in the following format:
H_1 M_1 H_2 M_2 K | s = list(input())
for i in range(s.count("?")):
s[s.index("?")] = "D"
print("".join(s))
| Statement
In this problem, we use the 24-hour clock.
Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the
time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study
for K consecutive minutes while he is up. What is the length of the period in
which he can start studying? | [{"input": "10 0 15 0 30", "output": "270\n \n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly\nthree in the afternoon. It takes 30 minutes to do the study, so he can start\nit in the period between ten o'clock and half-past two. The length of this\nperiod is 270 minutes, so we should print 270.\n\n* * *"}, {"input": "10 0 12 0 120", "output": "0\n \n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly\nnoon. It takes 120 minutes to do the study, so he has to start it at exactly\nten o'clock. Thus, we should print 0."}] |
Print the length of the period in which he can start studying, as an integer.
* * * | s982849031 | Runtime Error | p02663 | Input is given from Standard Input in the following format:
H_1 M_1 H_2 M_2 K | def main(N, A):
num = 1
ans = 1
for i in range(N + 1):
num -= A[i]
if i < N:
num *= 2
ans += num
if num <= 0 and i < N:
return -1
eda = 0
for i in range(N + 1):
ans -= num
eda += A[N - i]
num -= eda
num = num // 2
if num <= 0:
break
return ans
N = int(input())
A = list(map(int, input().split()))
print(main(N, A))
| Statement
In this problem, we use the 24-hour clock.
Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the
time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study
for K consecutive minutes while he is up. What is the length of the period in
which he can start studying? | [{"input": "10 0 15 0 30", "output": "270\n \n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly\nthree in the afternoon. It takes 30 minutes to do the study, so he can start\nit in the period between ten o'clock and half-past two. The length of this\nperiod is 270 minutes, so we should print 270.\n\n* * *"}, {"input": "10 0 12 0 120", "output": "0\n \n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly\nnoon. It takes 120 minutes to do the study, so he has to start it at exactly\nten o'clock. Thus, we should print 0."}] |
Print the length of the period in which he can start studying, as an integer.
* * * | s250266650 | Accepted | p02663 | Input is given from Standard Input in the following format:
H_1 M_1 H_2 M_2 K | # K = int(input())
HMK = list(map(int, input().split()))
# s = input().split()
# S = input()
st = HMK[0] * 60 + HMK[1]
et = HMK[2] * 60 + HMK[3]
print(et - st - HMK[4])
| Statement
In this problem, we use the 24-hour clock.
Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the
time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study
for K consecutive minutes while he is up. What is the length of the period in
which he can start studying? | [{"input": "10 0 15 0 30", "output": "270\n \n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly\nthree in the afternoon. It takes 30 minutes to do the study, so he can start\nit in the period between ten o'clock and half-past two. The length of this\nperiod is 270 minutes, so we should print 270.\n\n* * *"}, {"input": "10 0 12 0 120", "output": "0\n \n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly\nnoon. It takes 120 minutes to do the study, so he has to start it at exactly\nten o'clock. Thus, we should print 0."}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.