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 |
|---|---|---|---|---|---|---|---|
Print the minimum cost incurred before reaching the goal.
* * * | s464667912 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | N, M, X = map(int, input().split())
A = list(map(int, input().split()))
count = 0
for i in range(X+1)
count += A.count(i)
ans = min(count, len(A)-count)
print(ans) | Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s143457271 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | A,,B,C = map(int,input().split())
List_one = [0]*B
List_one = list(map(int,input().split()))
List_one.append(C)
#LIst_one = List_one + [C]
#print (List_one)
List_one.sort()# List_two=List_one.sort()としたらNoneを返してしまう。
#print(List_one)
x = List_one.index(C)
if x+1>=B-x:
print(B-x)
else:
print(x+1)
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s607100416 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | #!/usr/bin/env python
# -*- coding: utf-8 -*-
N,M,X = map(int,input().split()) #整数の入力
a = [int(i) for i in range(M)] #検問所の入力
b=[]
c=[]
for i in range(X:N): #XからNの範囲の整数について
if i in a is True: #ある整数が検問所の整数として存在する
b.append(1)
for i in range(1:X): #1からX-1の範囲の整数について
if i in a is True: #ある整数が検問所の整数として存在する
c.append(1)
print(min(sum(b),sum(c))) #リストb,cの要素の和のうちいずれか小さいほうを出力
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s883926308 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | l = input().split()
N = int(l[0])
M = int(l[1])
X = int(l[2])
cost1 = 0
cost2 = 0
j = 0
k = input().split()
for (e in k):
if int(e) >= X:
j = k.index(e)
cost1 = cost1 + 1
for (i in range(j, M)):
cost2 = cost2 + 1
if cost1 > cost2:
print(cost1)
else:
print(cost2)
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s849494608 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | #!/usr/bin/env python
# -*- coding: utf-8 -*-
N,M,X = map(int,input().split()) #整数の入力
a = [int(i) for i in range(M)] #検問所の入力
b=[]
c=[]
for i in range(X:N): #XからNの範囲の整数について
if i in a is True: #ある整数が検問所の整数として存在する
b.append(1)
for i in range(1:X): #1からX-1の範囲の整数について
if i in a is True: #ある整数が検問所の整数として存在する
c.append(1) | Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s842018138 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | n,m,x=map(int,input().split())
a=list(map(int,input().split()))
1count=0
ncount=0
for i in range(x):
if a.count(i)==1:
1count+=1
for i in range(x,n+1):
if a.count(i)==1:
ncount+=1
print(min(1count,ncount))
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s332261286 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | n, m, x = map(int, input().split(' '))
ai = map(int, input().split(' '))
lcost, rcost = 0, 0
for gate in ai:
if gate < x:
lcost = += 1
else:
rcost = += 1
print(min(lcost, rcost)) | Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s874286899 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | n, m, x = map(int, input().split(' '))
ai = map(int, input().split(' '))
lcost, rcost = 0, 0
for gate in ai:
if gate < x:
lcost = lcost + 1
else:
rcost = rcost + 1
print(min(lcost, rcost)) | Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s635632888 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | n, m, x = map(int, input().split(' '))
ai = list(map(int, input().split(' ')))
lcost, rcost = 0, 0
for gate in ai:
if gate < x:
lcost = lcost + 1
else:
rcost = rcost + 1
print(min(lcost, rcost)) | Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s135863347 | Accepted | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | a, b, c = map(int, input().split())
L = list(map(int, input().split()))
print(min(len(set(L) & set(range(1, c))), len(set(L) & set(range(c + 1, a)))))
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s625323482 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | N, M, X=map(int, input().split())
list=[0]*(N+1)
m=list[int() for i in input().split()]
for i in m:
list[i]=1 | Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s023503868 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | n, m, x = map(int, input().split())
a = list(map(int, input().split()))
print(min(sum([1 for i in a if > x]), sum([1 for i in a if < x]))) | Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s900687743 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | n,m,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
ans=0
for i in range(m):
ans+=1 if a[i]<x
print(min(ans,m-ans)) | Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s266856884 | Accepted | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | # ABC094B - Toll Gates
n, m, x = list(map(int, input().rstrip().split()))
lst = sorted(list(map(int, input().rstrip().split())) + [x])
print(min(lst.index(x), m - lst.index(x)))
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s139013231 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | N, M, X=map(int, input().split())
list=[0]*(N+1)
m=list(int() for i in input().split())
for i in m:
list[i]=1
min(sum(list.loc[0:X]), sum(list.loc(X+1:N+1))) | Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s479221038 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | n, m, x = map(int, input().split())
P = list(map(int,input().split())
a, b = 0, 0
for i in range(m):
if P[i] > x:
a += 1
else:
b += 1
print(min(a, b)) | Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s942861826 | Accepted | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | N, M, X = map(int, input().split())
n = list(map(int, input().split()))
Ni = list(range(N, X, -1))
Nk = list(range(0, X))
Ni_set = set(Ni)
Nk_set = set(Nk)
n_set = set(n)
Ni_ten = list(Ni_set & n_set)
Nk_ten = list(Nk_set & n_set)
if len(Ni_ten) < len(Nk_ten):
print(len(Ni_ten))
else:
print(len(Nk_ten))
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s380673753 | Accepted | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li():
return map(int, stdin.readline().split())
def li_():
return map(lambda x: int(x) - 1, stdin.readline().split())
def lf():
return map(float, stdin.readline().split())
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
n, m, x = li()
a = list(li())
small = 0
large = 0
for ai in a:
if ai < x:
small += 1
else:
large += 1
print(min(small, large))
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s067829532 | Wrong Answer | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | n, m, x = map(int, input().split())
a_tmp = input().split()
a = []
for _ in a_tmp:
a.append(int(_))
cost_l = 0
cost_r = 0
j = 0
for i in range(n + 1):
if i < x:
if i == a[j]:
cost_l += 1
j += 1
if j >= len(a):
break
elif x < i:
if i == a[j]:
cost_r += 1
j += 1
if j >= len(a):
break
else:
continue
print(cost_l, cost_r)
print(min(cost_l, cost_r))
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s319009053 | Wrong Answer | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | n, m, x = map(int, input().split())
la = list(map(int, input().split()))
count = 0
if n % 2 == 0:
if n // 2 > x:
while x >= 0:
for i in la:
if x == i:
count += 1
x -= 1
else:
while x <= n:
for i in la:
if x == i:
count += 1
x += 1
else:
if n // 2 + 1 > x:
while x >= 0:
for i in la:
if x == i:
count += 1
x -= 1
else:
while x <= n:
for i in la:
if x == i:
count += 1
x += 1
print(count)
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s434568435 | Accepted | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | N, M, X = map(int, input().split())
Ai = list(map(int, input().split()))
m = [i for i in Ai if i < X]
M = [o for o in Ai if o > X]
a = len(m)
b = len(M)
if a > b:
print(b)
if b > a:
print(a)
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s232877500 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | a = int(input())
x = list(map(float, input().split()))
m = max(x)
M = m / 2
t = 0
s = float("INF")
for i in x:
print(s, abs(M - i), i, M)
if s >= abs(M - i):
s = min(s, abs(M - i))
t = i
print(str(int(m)) + " " + str(int(t)))
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s429810190 | Wrong Answer | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | n, m, x = input().split()
n = int(n)
m = int(m)
x = int(x)
c = [0 for _ in range(n + 1)]
a = input().split()
for i in range(m):
c[int(a[i])] = 1
min(sum(c[:x]), sum(c[x:]))
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s450101704 | Accepted | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | (
N,
M,
X,
) = map(
int, input().rstrip().split()
) # input parameters
A = list(map(int, input().rstrip().split())) # input parameters
work1 = []
work2 = []
for i in range(len(A)):
if A[i] < X:
work1.append(A[i])
else:
work2.append(A[i])
print(min(len(work1), len(work2)))
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s547910502 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | #!/usr/bin/env python
# -*- coding: utf-8 -*-
N,M,X = map(int,input().split()) #整数の入力
a = list(map(int,input().split()))
#検問所の入力
b=[]
c=[]
for i in range(X+1,N): #X+1からNの範囲の整数について
if i in a: #ある整数が検問所の整数として存在する
b.append(1)
for i in range(1,X): #1からX-1の範囲の整数について
if i in a: #ある整数が検問所の整数として存在する
c.append(1)
print(min(sum(b),sum(c)) | Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s281297908 | Runtime Error | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | N, M, X = map(int, input().split())
A = list(map(int,input().split()))
A.append(N)
for i in range(M):
if A[0] > X or A[M-1] < X:
print(0)
else A[i] < X < A[i+1]:
print(min(i+1, M-i-1))
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the minimum cost incurred before reaching the goal.
* * * | s621490047 | Wrong Answer | p03378 | Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M | N, M, X = map(int, input().split())
A_list = [int(x) for x in input().split()]
minus_counter = 0
plus_counter = 0
for i in range(len(A_list)):
if A_list[i] > M:
break
minus_counter += 1
for i in range(minus_counter, len(A_list)):
plus_counter += 1
print(min(minus_counter, plus_counter))
| Statement
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to
right.
Initially, you are in Square X. You can freely travel between adjacent
squares. Your goal is to reach Square 0 or Square N. However, for each i = 1,
2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i
incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0,
Square X and Square N.
Find the minimum cost incurred before reaching the goal. | [{"input": "5 3 3\n 1 2 4", "output": "1\n \n\nThe optimal solution is as follows:\n\n * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n 4 5 6", "output": "0\n \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n 1 2 3 4 6 8 9", "output": "3"}] |
Print the number of operations that are necessary until the permutation is
sorted.
* * * | s424443845 | Wrong Answer | p03728 | Input is given from Standard Input in the following format:
N
p_1 p_2 ... p_N | N = int(input())
p1 = list(map(int, input().split()))
p2 = []
count = 0
flag = 0
flag2 = 1
while flag2 == 1:
flag = 0
flag2 = 0
MAX = 0
for i in range(N):
if p1[i] > MAX:
MAX = p1[i]
flag = flag + 1
p2.append(p1[i])
else:
L = len(p2)
p2.insert(L - flag, p1[i])
if i > 0:
if p2[L - flag] > p2[L - flag + 1]:
flag2 = 1
elif flag < L:
if p2[L - flag - 1] > p2[L - flag]:
flag2 = 1
p1 = p2[:]
count = count + 1
p2.clear()
print(count)
| Statement
Takahashi loves sorting.
He has a permutation (p_1,p_2,...,p_N) of the integers from 1 through N. Now,
he will repeat the following operation until the permutation becomes
(1,2,...,N):
* First, we will define _high_ and _low_ elements in the permutation, as follows. The i-th element in the permutation is high if the maximum element between the 1-st and i-th elements, inclusive, is the i-th element itself, and otherwise the i-th element is low.
* Then, let a_1,a_2,...,a_k be the values of the high elements, and b_1,b_2,...,b_{N-k} be the values of the low elements in the current permutation, **in the order they appear in it**.
* Lastly, rearrange the permutation into (b_1,b_2,...,b_{N-k},a_1,a_2,...,a_k).
How many operations are necessary until the permutation is sorted? | [{"input": "5\n 3 5 1 2 4", "output": "3\n \n\nThe initial permutation is (3,5,1,2,4), and each operation changes it as\nfollows:\n\n * In the first operation, the 1-st and 2-nd elements are high, and the 3-rd, 4-th and 5-th are low. The permutation becomes: (1,2,4,3,5).\n * In the second operation, the 1-st, 2-nd, 3-rd and 5-th elements are high, and the 4-th is low. The permutation becomes: (3,1,2,4,5).\n * In the third operation, the 1-st, 4-th and 5-th elements are high, and the 2-nd and 3-rd and 5-th are low. The permutation becomes: (1,2,3,4,5).\n\n* * *"}, {"input": "5\n 5 4 3 2 1", "output": "4\n \n\n* * *"}, {"input": "10\n 2 10 5 7 3 6 4 9 8 1", "output": "6"}] |
Print the number of operations that are necessary until the permutation is
sorted.
* * * | s851775984 | Wrong Answer | p03728 | Input is given from Standard Input in the following format:
N
p_1 p_2 ... p_N | n = int(input())
p = list(map(int, input().split()))
count = n - 1
while True:
tmp = p.index(max(p))
p.remove(max(p))
if p == []:
break
if p.index(max(p)) < tmp:
count -= 1
print(count + 1)
| Statement
Takahashi loves sorting.
He has a permutation (p_1,p_2,...,p_N) of the integers from 1 through N. Now,
he will repeat the following operation until the permutation becomes
(1,2,...,N):
* First, we will define _high_ and _low_ elements in the permutation, as follows. The i-th element in the permutation is high if the maximum element between the 1-st and i-th elements, inclusive, is the i-th element itself, and otherwise the i-th element is low.
* Then, let a_1,a_2,...,a_k be the values of the high elements, and b_1,b_2,...,b_{N-k} be the values of the low elements in the current permutation, **in the order they appear in it**.
* Lastly, rearrange the permutation into (b_1,b_2,...,b_{N-k},a_1,a_2,...,a_k).
How many operations are necessary until the permutation is sorted? | [{"input": "5\n 3 5 1 2 4", "output": "3\n \n\nThe initial permutation is (3,5,1,2,4), and each operation changes it as\nfollows:\n\n * In the first operation, the 1-st and 2-nd elements are high, and the 3-rd, 4-th and 5-th are low. The permutation becomes: (1,2,4,3,5).\n * In the second operation, the 1-st, 2-nd, 3-rd and 5-th elements are high, and the 4-th is low. The permutation becomes: (3,1,2,4,5).\n * In the third operation, the 1-st, 4-th and 5-th elements are high, and the 2-nd and 3-rd and 5-th are low. The permutation becomes: (1,2,3,4,5).\n\n* * *"}, {"input": "5\n 5 4 3 2 1", "output": "4\n \n\n* * *"}, {"input": "10\n 2 10 5 7 3 6 4 9 8 1", "output": "6"}] |
Print the maximum possible sum of the values of items Takahashi picks up.
* * * | s394550140 | Runtime Error | p02586 | Input is given from Standard Input in the following format:
R C K
r_1 c_1 v_1
r_2 c_2 v_2
:
r_K c_K v_K | h, w, n = map(int, input().split())
dp = [[[0] * 4 for _ in range(w + 1)] for _ in range(h + 1)]
v = [[0] * (w + 1) for _ in range(h + 1)]
for _ in range(n):
r, c, f = map(int, input().split())
v[r][c] = f
for i in range(1, h + 1):
for x in 0, 1, 2:
for j in range(1, w + 1):
dp[i][j][x + 1] = max(
dp[i][j][x],
max(dp[i][j + 1][x], (x < 1) * dp[i + 1][j][3]) + v[i][j],
dp[i + 1][j][x + 1],
)
print(dp[-1][-1][-1])
| Statement
There are K items placed on a grid of squares with R rows and C columns. Let
(i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column
(1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i.
Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When
he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a
non-existent square).
He can pick up items on the squares he visits, including the start and the
goal, but at most three for each row. It is allowed to ignore the item on a
square he visits.
Find the maximum possible sum of the values of items he picks up. | [{"input": "2 2 3\n 1 1 3\n 2 1 4\n 1 2 5", "output": "8\n \n\nHe has two ways to get to the goal:\n\n * Visit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n * Visit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\n* * *"}, {"input": "2 5 5\n 1 1 3\n 2 4 20\n 1 2 1\n 1 3 4\n 1 4 2", "output": "29\n \n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\n * Visit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\n* * *"}, {"input": "4 5 10\n 2 5 12\n 1 5 12\n 2 3 15\n 1 2 20\n 1 1 28\n 2 4 26\n 3 2 27\n 4 5 21\n 3 5 10\n 1 3 10", "output": "142"}] |
Print the maximum possible sum of the values of items Takahashi picks up.
* * * | s849022502 | Accepted | p02586 | Input is given from Standard Input in the following format:
R C K
r_1 c_1 v_1
r_2 c_2 v_2
:
r_K c_K v_K | import sys
def input():
return sys.stdin.buffer.readline()[:-1]
n, m, q = map(int, input().split())
g = [[0 for _ in range(m)] for _ in range(n)]
for _ in range(q):
r, c, v = list(map(int, input().split()))
g[r - 1][c - 1] = v
pre = [0 for _ in range(m)]
dp = [[0 for _ in range(4)] for _ in range(m)]
dp[0][1] = g[0][0]
for i in range(n):
for j in range(m):
dp[j][0] = max(dp[j][0], pre[j])
if j > 0:
dp[j][0] = max(dp[j][0], dp[j - 1][0])
for k in range(1, 4):
dp[j][k] = max(dp[j][k], dp[j - 1][k])
dp[j][k] = max(dp[j][k], dp[j - 1][k - 1] + g[i][j])
if i > 0:
dp[j][1] = max(dp[j][1], pre[j] + g[i][j])
else:
dp[0][1] = max(dp[0][1], pre[0] + g[i][j])
pre = [max(dp[j]) for j in range(m)]
dp = [[0 for _ in range(4)] for _ in range(m)]
print(pre[-1])
| Statement
There are K items placed on a grid of squares with R rows and C columns. Let
(i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column
(1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i.
Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When
he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a
non-existent square).
He can pick up items on the squares he visits, including the start and the
goal, but at most three for each row. It is allowed to ignore the item on a
square he visits.
Find the maximum possible sum of the values of items he picks up. | [{"input": "2 2 3\n 1 1 3\n 2 1 4\n 1 2 5", "output": "8\n \n\nHe has two ways to get to the goal:\n\n * Visit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n * Visit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\n* * *"}, {"input": "2 5 5\n 1 1 3\n 2 4 20\n 1 2 1\n 1 3 4\n 1 4 2", "output": "29\n \n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\n * Visit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\n* * *"}, {"input": "4 5 10\n 2 5 12\n 1 5 12\n 2 3 15\n 1 2 20\n 1 1 28\n 2 4 26\n 3 2 27\n 4 5 21\n 3 5 10\n 1 3 10", "output": "142"}] |
Print the maximum possible sum of the values of items Takahashi picks up.
* * * | s143356978 | Accepted | p02586 | Input is given from Standard Input in the following format:
R C K
r_1 c_1 v_1
r_2 c_2 v_2
:
r_K c_K v_K | c = [[0] * 3001 for _ in range(3001)]
dp = [[[0] * 3001 for _ in range(3001)] for _ in range(4)]
h, w, k = map(int, input().split())
for i in range(k):
y, x, v = map(int, input().split())
c[y][x] = v
for i in range(1, h + 1):
for j in range(1, w + 1):
x = max(dp[0][i - 1][j], dp[1][i - 1][j], dp[2][i - 1][j], dp[3][i - 1][j])
for k in range(4):
if k:
dp[k][i][j] = max(dp[k][i][j - 1], dp[k - 1][i][j - 1] + c[i][j])
else:
dp[k][i][j] = max(dp[k][i][j - 1], x)
dp[1][i][j] = max(dp[1][i][j], x + c[i][j])
print(max(dp[0][h][w], dp[1][h][w], dp[2][h][w], dp[3][h][w]))
| Statement
There are K items placed on a grid of squares with R rows and C columns. Let
(i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column
(1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i.
Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When
he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a
non-existent square).
He can pick up items on the squares he visits, including the start and the
goal, but at most three for each row. It is allowed to ignore the item on a
square he visits.
Find the maximum possible sum of the values of items he picks up. | [{"input": "2 2 3\n 1 1 3\n 2 1 4\n 1 2 5", "output": "8\n \n\nHe has two ways to get to the goal:\n\n * Visit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n * Visit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\n* * *"}, {"input": "2 5 5\n 1 1 3\n 2 4 20\n 1 2 1\n 1 3 4\n 1 4 2", "output": "29\n \n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\n * Visit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\n* * *"}, {"input": "4 5 10\n 2 5 12\n 1 5 12\n 2 3 15\n 1 2 20\n 1 1 28\n 2 4 26\n 3 2 27\n 4 5 21\n 3 5 10\n 1 3 10", "output": "142"}] |
Print the maximum possible sum of the values of items Takahashi picks up.
* * * | s290347767 | Runtime Error | p02586 | Input is given from Standard Input in the following format:
R C K
r_1 c_1 v_1
r_2 c_2 v_2
:
r_K c_K v_K | import sys
sys.setrecursionlimit(10**7)
def I():
return int(sys.stdin.readline().rstrip())
def MI():
return map(int, sys.stdin.readline().rstrip().split())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり
def LI2():
return list(map(int, sys.stdin.readline().rstrip())) # 空白なし
def S():
return sys.stdin.readline().rstrip()
def LS():
return list(sys.stdin.readline().rstrip().split()) # 空白あり
def LS2():
return list(sys.stdin.readline().rstrip()) # 空白なし
R, C, K = MI()
item = [[0] * (C + 1) for _ in range(R + 1)]
for i in range(K):
r, c, v = MI()
item[r][c] = v
dp = [[[0] * (C + 1) for j in range(4)] for i in range(R + 1)]
for i in range(1, R + 1):
for j in range(4):
for k in range(1, C + 1):
if item[i][k] == 0:
if i < R and k < C:
dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k])
dp[i + 1][0][k] = max(dp[i + 1][0][k], dp[i][j][k])
elif i < R and k == C:
dp[i + 1][0][k] = max(dp[i + 1][0][k], dp[i][j][k])
elif i == R and K < C:
dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k])
else:
if i < R and k < C:
dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k])
dp[i + 1][0][k] = max(dp[i + 1][0][k], dp[i][j][k])
elif i < R and k == C:
dp[i + 1][0][k] = max(dp[i + 1][0][k], dp[i][j][k])
elif i == R and K < C:
dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k])
if j != 3:
dp[i][j + 1][k] += item[i][k]
if i < R and k < C:
dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j + 1][k])
dp[i + 1][0][k] = max(dp[i + 1][0][k], dp[i][j + 1][k])
elif i < R and k == C:
dp[i + 1][0][k] = max(dp[i + 1][0][k], dp[i][j + 1][k])
elif i == R and K < C:
dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j + 1][k])
ans = 0
for j in range(4):
ans = max(ans, dp[R][j][C])
print(dp[R][j][C])
print(ans)
| Statement
There are K items placed on a grid of squares with R rows and C columns. Let
(i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column
(1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i.
Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When
he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a
non-existent square).
He can pick up items on the squares he visits, including the start and the
goal, but at most three for each row. It is allowed to ignore the item on a
square he visits.
Find the maximum possible sum of the values of items he picks up. | [{"input": "2 2 3\n 1 1 3\n 2 1 4\n 1 2 5", "output": "8\n \n\nHe has two ways to get to the goal:\n\n * Visit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n * Visit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\n* * *"}, {"input": "2 5 5\n 1 1 3\n 2 4 20\n 1 2 1\n 1 3 4\n 1 4 2", "output": "29\n \n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\n * Visit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\n* * *"}, {"input": "4 5 10\n 2 5 12\n 1 5 12\n 2 3 15\n 1 2 20\n 1 1 28\n 2 4 26\n 3 2 27\n 4 5 21\n 3 5 10\n 1 3 10", "output": "142"}] |
Print the maximum possible sum of the values of items Takahashi picks up.
* * * | s271380993 | Accepted | p02586 | Input is given from Standard Input in the following format:
R C K
r_1 c_1 v_1
r_2 c_2 v_2
:
r_K c_K v_K | H, W, k = map(int, input().split())
# アイテムが何処に何個あるか
fs = [[0] * (W + 1) for i in range(H + 1)]
for i in range(k):
h, w, v = map(int, input().split())
h -= 1
w -= 1
fs[h][w] = v
mvs = [(0, 1), (1, 0)]
dp = [[[-1 << 50 for i in range(W + 1)] for j in range(H + 1)] for k in range(4)]
# dp[n][i][j] n個取ったときの、i,jにおけるアイテム価値の最大値
from collections import deque
q = deque([])
q.append((0, 0))
dp[0][0][0] = 0
dp[1][0][0] = fs[0][0]
for h in range(H):
for w in range(W):
dp[0][h][w + 1] = max(dp[0][h][w + 1], dp[0][h][w])
dp[1][h][w + 1] = max(dp[1][h][w + 1], dp[1][h][w], dp[0][h][w] + fs[h][w + 1])
dp[2][h][w + 1] = max(dp[2][h][w + 1], dp[2][h][w], dp[1][h][w] + fs[h][w + 1])
dp[3][h][w + 1] = max(dp[3][h][w + 1], dp[3][h][w], dp[2][h][w] + fs[h][w + 1])
for w in range(W):
mx = 0
for i in range(4):
# print("fe",i,h,w,"dp",dp[i][h][w])
mx = max(mx, dp[i][h][w])
dp[0][h + 1][w] = mx
dp[1][h + 1][w] = mx + fs[h + 1][w]
H -= 1
W -= 1
ans0 = dp[0][H][W]
ans1 = dp[1][H][W]
ans2 = dp[2][H][W]
ans3 = dp[3][H][W]
# print(fs)
# for i in range(3):
# d = dp[i]
# for r in d:
# print(*r)
# print("----------")
print(max(ans1, ans2, ans3))
| Statement
There are K items placed on a grid of squares with R rows and C columns. Let
(i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column
(1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i.
Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When
he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a
non-existent square).
He can pick up items on the squares he visits, including the start and the
goal, but at most three for each row. It is allowed to ignore the item on a
square he visits.
Find the maximum possible sum of the values of items he picks up. | [{"input": "2 2 3\n 1 1 3\n 2 1 4\n 1 2 5", "output": "8\n \n\nHe has two ways to get to the goal:\n\n * Visit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n * Visit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\n* * *"}, {"input": "2 5 5\n 1 1 3\n 2 4 20\n 1 2 1\n 1 3 4\n 1 4 2", "output": "29\n \n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\n * Visit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\n* * *"}, {"input": "4 5 10\n 2 5 12\n 1 5 12\n 2 3 15\n 1 2 20\n 1 1 28\n 2 4 26\n 3 2 27\n 4 5 21\n 3 5 10\n 1 3 10", "output": "142"}] |
Print the maximum possible sum of the values of items Takahashi picks up.
* * * | s572344221 | Accepted | p02586 | Input is given from Standard Input in the following format:
R C K
r_1 c_1 v_1
r_2 c_2 v_2
:
r_K c_K v_K | import sys
from itertools import islice
def resolve(in_):
R, C, K = map(int, next(in_).split())
_rcv = (map(int, line.split()) for line in islice(in_, K))
R1 = R + 1
C1 = C + 1
R2 = R + 2
C2 = C + 2
limit_item = 3
limit_item1 = limit_item + 1
C2limit_item1 = C2 * limit_item1
# grid = [[0] * C2 for _ in range(R2)]
grid = [0] * (R2 * C2)
for r, c, v in _rcv:
# grid[r][c] = v
grid[(r * C2) + c] = v
# dp = [[[0] * limit_item1 for j in range(C2)] for i in range(R2)]
dp = [0] * (R2 * C2 * limit_item1)
# dp[1][1][1] = grid[1][1]
dp[(1 * C2limit_item1) + (1 * limit_item1) + 1] = grid[(1 * C2) + 1]
for i in range(1, R1):
for j in range(1, C1):
for k in range(limit_item1):
# current = dp[i][j][k]
current = dp[(i * C2limit_item1) + (j * limit_item1) + k]
# left = grid[i][j + 1]
left = grid[(i * C2) + (j + 1)]
# dp[i][j + 1][k] = max(dp[i][j + 1][k], current)
dp[(i * C2limit_item1) + ((j + 1) * limit_item1) + k] = max(
dp[(i * C2limit_item1) + ((j + 1) * limit_item1) + k], current
)
if k < limit_item:
# dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], left + current)
dp[(i * C2limit_item1) + ((j + 1) * limit_item1) + (k + 1)] = max(
dp[(i * C2limit_item1) + ((j + 1) * limit_item1) + (k + 1)],
left + current,
)
# top = grid[i + 1][j]
top = grid[((i + 1) * C2) + j]
# dp[i + 1][j][0] = max(dp[i + 1][j][0], current)
dp[(i + 1) * C2limit_item1 + (j * limit_item1) + 0] = max(
dp[(i + 1) * C2limit_item1 + (j * limit_item1) + 0], current
)
# dp[i + 1][j][1] = max(dp[i + 1][j][1], top + current)
dp[(i + 1) * C2limit_item1 + (j * limit_item1) + 1] = max(
dp[(i + 1) * C2limit_item1 + (j * limit_item1) + 1], top + current
)
# return max(dp[R][C])
return max(
dp[
(R * C2limit_item1)
+ (C * limit_item1) : ((R + 1) * C2limit_item1)
+ ((C + 1) * limit_item1)
]
)
def main():
answer = resolve(sys.stdin.buffer)
print(answer)
if __name__ == "__main__":
main()
| Statement
There are K items placed on a grid of squares with R rows and C columns. Let
(i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column
(1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i.
Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When
he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a
non-existent square).
He can pick up items on the squares he visits, including the start and the
goal, but at most three for each row. It is allowed to ignore the item on a
square he visits.
Find the maximum possible sum of the values of items he picks up. | [{"input": "2 2 3\n 1 1 3\n 2 1 4\n 1 2 5", "output": "8\n \n\nHe has two ways to get to the goal:\n\n * Visit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n * Visit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\n* * *"}, {"input": "2 5 5\n 1 1 3\n 2 4 20\n 1 2 1\n 1 3 4\n 1 4 2", "output": "29\n \n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\n * Visit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\n* * *"}, {"input": "4 5 10\n 2 5 12\n 1 5 12\n 2 3 15\n 1 2 20\n 1 1 28\n 2 4 26\n 3 2 27\n 4 5 21\n 3 5 10\n 1 3 10", "output": "142"}] |
Print the maximum possible sum of the values of items Takahashi picks up.
* * * | s375535138 | Accepted | p02586 | Input is given from Standard Input in the following format:
R C K
r_1 c_1 v_1
r_2 c_2 v_2
:
r_K c_K v_K | r, c, k = map(int, input().split())
v = [[0] * (c + 1) for i in range(r + 1)]
for i in range(k):
x, y, z = map(int, input().split())
v[x][y] = z
dp = [[0] * 4 for i in range(r + 1)]
for i in range(1, c + 1):
for j in range(1, r + 1):
if v[j][i] > 0:
dp[j][3] = max(dp[j][2] + v[j][i], dp[j][3])
dp[j][2] = max(dp[j][1] + v[j][i], dp[j][2])
dp[j][1] = max(dp[j][0] + v[j][i], dp[j][1], max(dp[j - 1]) + v[j][i])
dp[j][0] = max(dp[j][0], max(dp[j - 1]))
print(max(dp[r]))
| Statement
There are K items placed on a grid of squares with R rows and C columns. Let
(i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column
(1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i.
Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When
he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a
non-existent square).
He can pick up items on the squares he visits, including the start and the
goal, but at most three for each row. It is allowed to ignore the item on a
square he visits.
Find the maximum possible sum of the values of items he picks up. | [{"input": "2 2 3\n 1 1 3\n 2 1 4\n 1 2 5", "output": "8\n \n\nHe has two ways to get to the goal:\n\n * Visit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n * Visit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\n* * *"}, {"input": "2 5 5\n 1 1 3\n 2 4 20\n 1 2 1\n 1 3 4\n 1 4 2", "output": "29\n \n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\n * Visit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\n* * *"}, {"input": "4 5 10\n 2 5 12\n 1 5 12\n 2 3 15\n 1 2 20\n 1 1 28\n 2 4 26\n 3 2 27\n 4 5 21\n 3 5 10\n 1 3 10", "output": "142"}] |
Print the maximum possible sum of the values of items Takahashi picks up.
* * * | s242814270 | Accepted | p02586 | Input is given from Standard Input in the following format:
R C K
r_1 c_1 v_1
r_2 c_2 v_2
:
r_K c_K v_K | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
r, c, k = map(int, readline().split())
data = list(map(int, read().split()))
d = dict()
it = iter(data)
for ri, ci, vi in zip(it, it, it):
d[(ri - 1) * 5000 + (ci - 1)] = vi
dp_max = [0] * (c)
for i in range(r):
dp = [[0, 0, 0, 0] for _ in range(4)]
for j in range(c):
dp[0][0] = max(dp[0][0], dp_max[j])
if i * 5000 + j in d:
ci = d[i * 5000 + j]
# 3
if dp[3][0] != 0:
min_num = min(dp[3][1:4])
if min_num < ci:
dp[3][0] += ci - min_num
for k in range(1, 4):
if dp[3][k] == min_num:
dp[3][k] = ci
break
if dp[2][0] != 0:
if dp[3][0] <= dp[2][0] + ci:
dp[3][0] = dp[2][0] + ci
dp[3][1] = dp[2][1]
dp[3][2] = dp[2][2]
dp[3][3] = ci
# 2
if dp[1][0] != 0:
if dp[2][0] <= dp[1][0] + ci:
dp[2][0] = dp[1][0] + ci
dp[2][1] = dp[1][1]
dp[2][2] = ci
# 1
if dp[1][0] <= dp[0][0] + ci:
dp[1][0] = dp[0][0] + ci
dp[1][1] = ci
# print(i,j)
# print(dp)
dp_max[j] = max(dp[0][0], dp[1][0], dp[2][0], dp[3][0])
# print(i,j)
# print(dp_max)
print(dp_max[-1])
| Statement
There are K items placed on a grid of squares with R rows and C columns. Let
(i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column
(1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i.
Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When
he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a
non-existent square).
He can pick up items on the squares he visits, including the start and the
goal, but at most three for each row. It is allowed to ignore the item on a
square he visits.
Find the maximum possible sum of the values of items he picks up. | [{"input": "2 2 3\n 1 1 3\n 2 1 4\n 1 2 5", "output": "8\n \n\nHe has two ways to get to the goal:\n\n * Visit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n * Visit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\n* * *"}, {"input": "2 5 5\n 1 1 3\n 2 4 20\n 1 2 1\n 1 3 4\n 1 4 2", "output": "29\n \n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\n * Visit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\n* * *"}, {"input": "4 5 10\n 2 5 12\n 1 5 12\n 2 3 15\n 1 2 20\n 1 1 28\n 2 4 26\n 3 2 27\n 4 5 21\n 3 5 10\n 1 3 10", "output": "142"}] |
Print the maximum possible sum of the values of items Takahashi picks up.
* * * | s176833348 | Accepted | p02586 | Input is given from Standard Input in the following format:
R C K
r_1 c_1 v_1
r_2 c_2 v_2
:
r_K c_K v_K | R, C, K = list(map(int, input().split()))
rcv = [list(map(int, input().split())) for _ in range(K)]
rcv.sort()
rcv.append([R, C, 0])
L = [0] * C
su = 0
n = 0
vv = 0
D = [0, 0, 0]
for i in range(K):
r, c, v = rcv[i]
if r != 1:
break
for j in range(3):
if D[j] < v:
D[j], v = v, D[j]
L[c - 1] = sum(D)
n = i
for i in range(1, C):
L[i] = max(L[i], L[i - 1])
for i in range(2, R + 1):
L2 = L
L = [0] * C
D = [0, 0, 0]
DP = []
ln = 0
for n in range(n, K):
r, c, v = rcv[n]
if r != i:
break
if len(DP) == 0:
L[c - 1] = v + L2[c - 1]
D[0] = L[c - 1]
DP.append([L[c - 1], 0, 0])
continue
DP.append([0, 0, 0])
DP[-1][0] = v + L2[c - 1]
for k in range(3):
DP[-1][k] = max(DP[-1][k], DP[-2][k])
if k == 0:
continue
DP[-1][k] = max(DP[-1][k], DP[-2][k - 1] + v)
L[c - 1] = max(DP[-1])
L[0] = max(L[0], L2[0])
for j in range(1, C):
L[j] = max(L[j], L[j - 1], L2[j])
print(max(L))
| Statement
There are K items placed on a grid of squares with R rows and C columns. Let
(i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column
(1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i.
Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When
he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a
non-existent square).
He can pick up items on the squares he visits, including the start and the
goal, but at most three for each row. It is allowed to ignore the item on a
square he visits.
Find the maximum possible sum of the values of items he picks up. | [{"input": "2 2 3\n 1 1 3\n 2 1 4\n 1 2 5", "output": "8\n \n\nHe has two ways to get to the goal:\n\n * Visit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n * Visit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\n* * *"}, {"input": "2 5 5\n 1 1 3\n 2 4 20\n 1 2 1\n 1 3 4\n 1 4 2", "output": "29\n \n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\n * Visit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\n* * *"}, {"input": "4 5 10\n 2 5 12\n 1 5 12\n 2 3 15\n 1 2 20\n 1 1 28\n 2 4 26\n 3 2 27\n 4 5 21\n 3 5 10\n 1 3 10", "output": "142"}] |
Print the maximum possible sum of the values of items Takahashi picks up.
* * * | s509328600 | Wrong Answer | p02586 | Input is given from Standard Input in the following format:
R C K
r_1 c_1 v_1
r_2 c_2 v_2
:
r_K c_K v_K | import copy
from collections import defaultdict as dd
r, c, k = map(int, input().split())
# cnt[col][row] => val
cnt = dd(lambda: dd(int))
for i in range(k):
row, col, v = map(int, input().split())
cnt[row][col] = v
def replace(cand, val):
cand_val, cand_add_vals = copy.deepcopy(cand)
for i in range(len(cand_add_vals)):
if cand_add_vals[i] < val:
cand_add_vals[i] = val
cand_add_vals.sort()
break
return [cand_val, cand_add_vals]
def eval(arr):
# arr = [past_val, add_vals:[a1, a2, a3]]
past_val, add_vals = arr
return past_val + sum(add_vals)
dp = [[[0, [0, 0, 0]] for i in range(c + 1)] for j in range(r + 1)]
# dp[col][lowest_row] => [val1, val2, val3(biggest)]
for row in range(1, r + 1):
for col in range(1, c + 1):
# add_vals = [0, 0, 0]
val = cnt[row][col]
# print(row, col, val)
# left
cand1 = dp[row][col - 1]
cand1 = replace(cand1, val)
# up
cand2 = dp[row - 1][col]
cand2 = [eval(cand2), [0, 0, val]]
# print(cand1, cand2)
if eval(cand1) > eval(cand2):
dp[row][col] = cand1
elif eval(cand1) <= eval(cand2):
dp[row][col] = cand2
print(eval(dp[r][c]))
| Statement
There are K items placed on a grid of squares with R rows and C columns. Let
(i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column
(1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i.
Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When
he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a
non-existent square).
He can pick up items on the squares he visits, including the start and the
goal, but at most three for each row. It is allowed to ignore the item on a
square he visits.
Find the maximum possible sum of the values of items he picks up. | [{"input": "2 2 3\n 1 1 3\n 2 1 4\n 1 2 5", "output": "8\n \n\nHe has two ways to get to the goal:\n\n * Visit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n * Visit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\n* * *"}, {"input": "2 5 5\n 1 1 3\n 2 4 20\n 1 2 1\n 1 3 4\n 1 4 2", "output": "29\n \n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\n * Visit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\n* * *"}, {"input": "4 5 10\n 2 5 12\n 1 5 12\n 2 3 15\n 1 2 20\n 1 1 28\n 2 4 26\n 3 2 27\n 4 5 21\n 3 5 10\n 1 3 10", "output": "142"}] |
Print the maximum possible sum of the values of items Takahashi picks up.
* * * | s997737638 | Accepted | p02586 | Input is given from Standard Input in the following format:
R C K
r_1 c_1 v_1
r_2 c_2 v_2
:
r_K c_K v_K | f = lambda: map(int, input().split())
g = range
R, C, K = f()
a = [[0] * (R + 1) for _ in g(C + 1)]
for _ in g(K):
r, c, v = f()
a[c][r] = v
dp = [[0] * 4 for _ in g(R + 1)]
for i in g(1, C + 1):
for j in g(1, R + 1):
t = a[i][j]
if t:
for k in [3, 2, 1]:
dp[j][k] = max(dp[j][k], dp[j][k - 1] + t)
dp[j][1] = max(dp[j][1], max(dp[j - 1]) + t)
dp[j][0] = max(dp[j][0], max(dp[j - 1]))
print(max(dp[R]))
| Statement
There are K items placed on a grid of squares with R rows and C columns. Let
(i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column
(1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i.
Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When
he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a
non-existent square).
He can pick up items on the squares he visits, including the start and the
goal, but at most three for each row. It is allowed to ignore the item on a
square he visits.
Find the maximum possible sum of the values of items he picks up. | [{"input": "2 2 3\n 1 1 3\n 2 1 4\n 1 2 5", "output": "8\n \n\nHe has two ways to get to the goal:\n\n * Visit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n * Visit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\n* * *"}, {"input": "2 5 5\n 1 1 3\n 2 4 20\n 1 2 1\n 1 3 4\n 1 4 2", "output": "29\n \n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\n * Visit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\n* * *"}, {"input": "4 5 10\n 2 5 12\n 1 5 12\n 2 3 15\n 1 2 20\n 1 1 28\n 2 4 26\n 3 2 27\n 4 5 21\n 3 5 10\n 1 3 10", "output": "142"}] |
Print the maximum possible sum of the values of items Takahashi picks up.
* * * | s954714837 | Runtime Error | p02586 | Input is given from Standard Input in the following format:
R C K
r_1 c_1 v_1
r_2 c_2 v_2
:
r_K c_K v_K | N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
P = [P[i] - 1 for i in range(N)]
loop_list = [] # ([indexes])
loop_score_list = []
loop_index_list = [0] * N
is_included_loop = [0] * N
num_loop = 0
for start in range(N):
if is_included_loop[start]:
continue
now = start
count = 1
visited = [-1] * N # count
visited[now] = 0
while True:
now = P[now]
if visited[now] != -1:
terminate_count = count
start_count = visited[now]
loop_start_idx = now
break
visited[now] = count
count += 1
num_loop += 1
now = loop_start_idx
loop_indexes = [now]
visited = [-1] * N
visited[now] = 0
count = 1
loop_score = 0
while True:
now = P[now]
if visited[now] != -1:
break
loop_indexes.append(now)
visited[now] = count
loop_index_list[now] = num_loop
loop_score += C[now]
is_included_loop[now] = 1
loop_list.append(loop_indexes)
loop_score_list.append(loop_score)
scores = []
for start in range(N):
tmp_score = 0
rest = K
now = start
while not is_included_loop[now] and rest > 0:
now = P[now]
rest -= 1
tmp_score += C[now]
scores.append(tmp_score)
if rest <= 0:
scores.append(tmp_score)
continue
# loop
number_of_loop = loop_index_list[now] - 1
one_cicle_score = loop_score_list[number_of_loop]
if one_cicle_score < 0:
continue
if rest <= len(loop_list[number_of_loop]):
while rest >= 0:
now = P[now]
rest -= 1
tmp_score += C[now]
scores.append(tmp_score)
continue
else:
n_l = rest // len(loop_list[number_of_loop])
tmp_score += n_l * one_cicle_score
scores.append(tmp_score)
print(max(scores))
| Statement
There are K items placed on a grid of squares with R rows and C columns. Let
(i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column
(1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i.
Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When
he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a
non-existent square).
He can pick up items on the squares he visits, including the start and the
goal, but at most three for each row. It is allowed to ignore the item on a
square he visits.
Find the maximum possible sum of the values of items he picks up. | [{"input": "2 2 3\n 1 1 3\n 2 1 4\n 1 2 5", "output": "8\n \n\nHe has two ways to get to the goal:\n\n * Visit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n * Visit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\n* * *"}, {"input": "2 5 5\n 1 1 3\n 2 4 20\n 1 2 1\n 1 3 4\n 1 4 2", "output": "29\n \n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\n * Visit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\n* * *"}, {"input": "4 5 10\n 2 5 12\n 1 5 12\n 2 3 15\n 1 2 20\n 1 1 28\n 2 4 26\n 3 2 27\n 4 5 21\n 3 5 10\n 1 3 10", "output": "142"}] |
Print the maximum possible sum of the values of items Takahashi picks up.
* * * | s752233398 | Runtime Error | p02586 | Input is given from Standard Input in the following format:
R C K
r_1 c_1 v_1
r_2 c_2 v_2
:
r_K c_K v_K | N, K = map(int, input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
C = list(map(int, input().split()))
done = [False] * N
ans = -(10**30)
must_negative = all([c < 0 for c in C])
for i in range(N):
if done[i]:
continue
loop = [i]
done[loop[-1]] = True
while not done[P[loop[-1]]]:
loop.append(P[loop[-1]])
done[loop[-1]] = True
# print(loop, done)
# print(loop)
scores = [C[i] for i in loop]
# print(scores)
cumsum = [0]
for s in scores * 2:
cumsum.append(cumsum[-1] + s)
# print(cumsum)
L = len(scores)
if cumsum[L] >= 0:
# (L+K) // L loops - max
l = max(0, (K - L) // L)
k_max = K - l * L
# print(l, k_max)
base_score = cumsum[L] * l
else:
k_max = min(K, L)
# print(k_max)
base_score = 0
for i in range(L):
for k in range(k_max + 1):
score = base_score + cumsum[i + k] - cumsum[i]
# print(i, k, base_score, score)
if must_negative and score == 0:
continue
ans = max(ans, score)
print(ans)
| Statement
There are K items placed on a grid of squares with R rows and C columns. Let
(i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column
(1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i.
Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When
he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a
non-existent square).
He can pick up items on the squares he visits, including the start and the
goal, but at most three for each row. It is allowed to ignore the item on a
square he visits.
Find the maximum possible sum of the values of items he picks up. | [{"input": "2 2 3\n 1 1 3\n 2 1 4\n 1 2 5", "output": "8\n \n\nHe has two ways to get to the goal:\n\n * Visit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n * Visit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\n* * *"}, {"input": "2 5 5\n 1 1 3\n 2 4 20\n 1 2 1\n 1 3 4\n 1 4 2", "output": "29\n \n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\n * Visit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\n* * *"}, {"input": "4 5 10\n 2 5 12\n 1 5 12\n 2 3 15\n 1 2 20\n 1 1 28\n 2 4 26\n 3 2 27\n 4 5 21\n 3 5 10\n 1 3 10", "output": "142"}] |
Print the N-th Lucas number.
* * * | s782584741 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | N = int(input())
def fibn(a, b, k, n):
if k < n:
return fibn(b, a+b, k+1, n)
else:
return a+b
print(fibn(2,1,2,N))
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s532113076 | Accepted | p03544 | Input is given from Standard Input in the following format:
N | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
INF = 10**20
def I():
return int(input())
def F():
return float(input())
def S():
return input()
def LI():
return [int(x) for x in input().split()]
def LI_():
return [int(x) - 1 for x in input().split()]
def LF():
return [float(x) for x in input().split()]
def LS():
return input().split()
def resolve():
N = I()
lucas = [0] * (N + 1)
lucas[0] = 2
lucas[1] = 1
for i in range(N - 1):
lucas[i + 2] = lucas[i] + lucas[i + 1]
print(lucas[-1])
if __name__ == "__main__":
resolve()
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s320642989 | Accepted | p03544 | Input is given from Standard Input in the following format:
N | from statistics import mean, median, variance, stdev
import numpy as np
import sys
import math
import fractions
import itertools
def j(q):
if q == 1:
print("Yes")
else:
print("No")
exit(0)
def ct(x, y):
if x > y:
print("")
elif x < y:
print("")
else:
print("")
def ip():
return int(input())
def swap(s, pos):
s[pos] -= 1
s[pos + 1] += 1
print(s)
if pos == n - 2:
return s
if s[pos + 2] == 0:
swap(s, pos + 1)
return s
n = ip() # 入力整数1つ
# left,n= (int(i) for i in input().split()) #入力整数横2つ
# n,x,y = (int(i) for i in input().split()) #入力整数横3つ
# n,m,x,y= (int(i) for i in input().split()) #入力整数横4つ
# a = [int(i) for i in input().split()] #入力整数配列
# a = input() #入力文字列
# a = input().split() #入力文字配列
# n = ip() #入力セット(整数改行あり)(1/2)
# a=[ip() for i in range(n)] #入力セット(整数改行あり)(2/2)
# jの変数はしようできないので注意
# 全足しにsum変数使用はsum関数使用できないので注意
a = [2, 1]
for i in range(n - 1):
a.append(a[i] + a[i + 1])
print(a[n])
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s330590711 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
{ cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
if (a < b)swap(a, b);
if (b == 0) return a;
unsigned r;
while ((r = a % b)) {
a = b;
b = r;
}
return b;
}
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a * b / g;
}
bool prime(ll n) {
for (ll i = 2; i <= sqrt(n); i++) {
if (n%i == 0)return false;
}
return n != 1;
}
Vec fac, finv;
ll PowMod(ll a, ll n){
if(n == 1) return a;
if(n%2 == 0) return PowMod(a*a%MOD, n/2);
return a*PowMod(a*a%MOD, n/2)%MOD;
}
ll combi(ll n, ll k){
if(k>n) return 0;
return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}
int main(){
int n;
cin >> n;
ll l[2] = {2, 1};
rep(i, n - 1){
l[i % 2] = l[0] + l[1];
}
cout << l[n % 2] << '\n';
} | Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s877386413 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | def memoize(f):
cache={}
def helper(*args):
if args not in cache:
cache[args] = f(*args)
return cache[args]
return helper
@memoize
def ans(N):
if N==0:
return 1
elif N==1:
return 2
else:
return ans(N-1)+ans(N-2)
N=int(input())
print(ans(N)) | Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s312185080 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n;
cin >> n;
vector<ll> l(100);
l[0] = 2;
l[1] = 1;
for (int i = 2; i <= n; i++)
{
l[i] = l[i-1] + l[i-2];
}
cout << l[n] << endl;
} | Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s942957051 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | a,b=2,1
for i in range(int(input()):
a,b=b,(a+b)
print(a) | Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s923825646 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | n = input()
if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
print("YES")
else:
print("NO")
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s332606637 | Accepted | p03544 | Input is given from Standard Input in the following format:
N | import math
from collections import deque
from collections import defaultdict
# 自作関数群
def readInt():
return int(input())
def readInts():
return list(map(int, input().split()))
def readChar():
return input()
def readChars():
return input().split()
def factorization(n):
res = []
if n % 2 == 0:
res.append(2)
for i in range(3, math.floor(n // 2) + 1, 2):
if n % i == 0:
c = 0
for j in res:
if i % j == 0:
c = 1
if c == 0:
res.append(i)
return res
def fact2(n):
p = factorization(n)
res = []
for i in p:
c = 0
z = n
while 1:
if z % i == 0:
c += 1
z /= i
else:
break
res.append([i, c])
return res
def fact(n): # 階乗
ans = 1
m = n
for _i in range(n - 1):
ans *= m
m -= 1
return ans
def comb(n, r): # コンビネーション
if n < r:
return 0
l = min(r, n - r)
m = n
u = 1
for _i in range(l):
u *= m
m -= 1
return u // fact(l)
def combmod(n, r, mod):
return (fact(n) / fact(n - r) * pow(fact(r), mod - 2, mod)) % mod
def printQueue(q):
r = copyQueue(q)
ans = [0] * r.qsize()
for i in range(r.qsize() - 1, -1, -1):
ans[i] = r.get()
print(ans)
class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x): # root
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -1 * self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x): # much time
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n): # ビット全探索
x = 1
zero = "0" * n
ans = []
ans.append([0] * n)
for i in range(2**n - 1):
ans.append(list(map(lambda x: int(x), list((zero + bin(x)[2:])[-1 * n :]))))
x += 1
return ans
def arrsSum(a1, a2):
for i in range(len(a1)):
a1[i] += a2[i]
return a1
def maxValue(a, b, v):
v2 = v
for i in range(v2, -1, -1):
for j in range(v2 // a + 1): # j:aの個数
k = i - a * j
if k % b == 0:
return i
return -1
def copyQueue(q):
nq = queue.Queue()
n = q.qsize()
for i in range(n):
x = q.get()
q.put(x)
nq.put(x)
return nq
def get_sieve_of_eratosthenes(n):
# data = [2]
data = [0, 0, 0]
for i in range(3, n + 1, 2):
data.append(i)
data.append(0)
for i in range(len(data)):
interval = data[i]
if interval != 0:
for j in range(i + interval, n - 1, interval):
data[j] = 0
# ans = [x for x in data if x!=0]
ans = data[:]
return ans
ryuka = [-1] * 87
ryuka[0] = 2
ryuka[1] = 1
for i in range(2, 87):
ryuka[i] = ryuka[i - 1] + ryuka[i - 2]
print(ryuka[readInt()])
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s448002770 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | n = int(input())
l0 = 2
l1 = 1
if n == 1:
print(l1)
else:
for i in range(2, n+1):
if i == 2:
li = l0
lj = l1
l = li + lj
li = lj
lj = l
print(l)
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s637058984 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | def luca(n):
if n == 2:
return 1
elif n == 1:
return 2
luca(n) = luca(n-1) + luca(n-2)
return
print(luca(int(input())) | Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s422942021 | Accepted | p03544 | Input is given from Standard Input in the following format:
N | L = [2 if i == 0 else 1 for i in range(100)]
for n in range(2, 100):
L[n] = L[n - 1] + L[n - 2]
print(L[int(input())])
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s879188233 | Wrong Answer | p03544 | Input is given from Standard Input in the following format:
N | i = int(input())
luca = [2, 1, 3]
for l in range(i - 2):
num = luca[-1] + luca[-2]
luca.append(num)
print(luca[-1])
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s644915772 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | input()
a = sorted(map(int, input().split()), reverse=True)
print(sum(a[0::2]) - sum(a[1::2]))
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s066015084 | Accepted | p03544 | Input is given from Standard Input in the following format:
N | import sys
sys.setrecursionlimit(10**8)
def ii():
return int(sys.stdin.readline())
def mi():
return map(int, sys.stdin.readline().split())
def li():
return list(map(int, sys.stdin.readline().split()))
def li2(N):
return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j):
return [[ini] * i for _ in range(j)]
def dp3(ini, i, j, k):
return [[[ini] * i for _ in range(j)] for _ in range(k)]
# import bisect #bisect.bisect_left(B, a)
# from collections import defaultdict #d = defaultdict(int) d[key] += value
# from itertools import accumulate #list(accumulate(A))
N = ii()
A = [0] * (N + 1)
A[0] = 2
A[1] = 1
for i in range(2, N + 1):
A[i] = A[i - 1] + A[i - 2]
print(A[N])
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s754239994 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | n = int(input())
LUKAS = [0, 2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349, 15127, 24476, 39603, 64079, 103682, 167761, 271443, 439204, 710647, 1149851, 1860498, 3010349, 4870847, 7881196, 12752043, 20633239, 33385282, 54018521, 87403803, 141422324, 228826127, 370248451, 599074578, 969323029, 1568397607, 2537720636, 4106118243, 6643838879, 10749957122, 17393796001, 28143753123, 45537549124, 73681302247, 119218851371, 192900153618, 312119004989, 505019158607, 817138163596, 1322157322203, 2139295485799, 3461452808002, 5600748293801, 9062201101803, 14662949395604, 23725150497407, 38388099893011, 62113250390418, 100501350283429, 162614600673847, 263115950957276, (71)425730551631123, 688846502588399, 1114577054219522, 1803423556807921, 2918000611027443, 4721424167835364, 7639424778862807, 12360848946632171, 20000273725560978, 32361122672259149, 52361396397820127, 84722519070079276, 137083915467899403, 221806434537978679, 358890350005878082, 580696784543856761, 939587134549734843]
print(LUKAS[n]) | Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s885858066 | Accepted | p03544 | Input is given from Standard Input in the following format:
N | n = int(input())
Lucas = [0] * 87
Lucas[0] = 2
Lucas[1] = 1
for i in range(87):
if i + 2 > n:
break
Lucas[i + 2] = Lucas[i + 1] + Lucas[i]
print(Lucas[n])
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s550980308 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | n = int(input())
l0 = 2
l1 = 1
if n == 1:
print(l1)
else:
for i in range(2, n+1):
if i == 2:
li = l0
lj = l1
l = li + lj
li = lj
lj = l
print(l)
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s918672723 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long int ulli;
typedef long long int lli;
#define pb(a) push_back(a)
#define pbb(a) pop_back(a)
#define ph(a) push_heap(a.begin(), a.end())
#define pph(a) pop_heap(a.begin(), a.end())
#define si set<int>
#define sl set<long>
#define sc set<char>
#define pii pair<int, int>
#define pll pair<long, long>
#define pdd pair<double, double>
#define TC(t) while(t--)
#define FORA(a,b,c) for ((a) == (b); (a) < (c); (a) ++)
#define FORB(a,b,c) for ((a) == (b); (a) <= (c); (a) ++)
#define FORC(a,b) for ((a) == (b); (a) > 0; (a)--)
#define FORD(a,b) for ((a) == (b); (a) >= 0; (a)--)
#define WM(a) while(a--)
#define WP(a) while(a++)
#define print(data) cout << data << endl
#define tin(a) cin >> a
#define ttin(a,b) cin >> a >> b
#define tttin(a,b,c) cin >> a >> b >> c
#define maxheap(a) make_heap(a.begin(),a.end())
#define fixp(a) cout << fixed << setprecision(a);
#define RM(a,n) a.erase(remopricee(a.begin(), a.end(), n),a.end())
#define MOD 1000000007
ll prime[] = {2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47};
inline int gmx (int a, int b){
return a > b ? a : b;
}
inline int gmm (int a, int b){
return a < b ? a : b;
}
inline ll get_gcd(ll a, ll b){
ll rem = 0;
while( b != 0){
rem = a % b;
a = b;
b = rem;
}
return a;
}
ll fastexp (ll base, ll exp){
ll res = 1;
if (exp == 0) return 1LL;
while(exp){
if(exp&1) res = (res*base)%MOD;
res = (res+MOD)%MOD;
base = (base*base)%MOD;
base = (base+MOD)%MOD;
exp >>= 1;
}
return (ll)res;
}
struct compare {
bool operator()(const std::string& first, const std::string& second) {
return first.size() < second.size();
}
};
void Verdict_Check(){
ifstream A("my_output.txt");
ifstream B("code_output.txt");
int c1=0,c2=0;
bool WA = false;
string str;
while(getline(A,str)){
c1++;
}
while(getline(B,str)){
c2++;
}
A.close();
B.close();
ifstream AA("my_output.txt");
ifstream BB("code_output.txt");
if (c1 != c2){
WA = true;
}else{
string s,ss;
while(getline(AA,s) && getline(BB,ss)){
if(s != ss){
WA = true;
}
}
}
if (WA){
cout << "Wrong answer!!!" << endl;
}else{
cout << "All test cases are passed!!!" << endl;
}
AA.close();
BB.close();
}
int N;
ll a[86+5];
int main(){
int A[10000];
//freopen("a.in","r",stdin);
//freopen("my_output.txt","a", stdout);
clock_t tStart = clock();
scanf("%d",&N);
a[0] = 2LL;a[1] = 1LL;
for (int i = 2; i <= N; i ++)a[i] = a[i-1] + a[i-2];
printf("%lld\n",a[N]);
//freopen("CON", "w", stdout);
//Verdict_Check();
// printf("Time taken: %.7fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
return 0;
} | Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s843652405 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | l_0 = 2
l_1 = 1
A = int(input())
if A == 0:
print(l_0)
elif A == 1:
print(l_1)
else:
for i in range(1,A+1):
if i%2 != 0
l_1 = l_0 + L_1
else:
l_0 = l_0 + L_1 | Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s623108917 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | fn main() {
let n: i32 = read();
let ans = lucas(n);
println!("{}", ans);
}
fn lucas(n: i32) -> i32 {
if n == 0 { 2 }
else if n == 1 { 1 }
else {
lucas(n-1) + lucas(n-2)
}
}
// 以下関数
use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
let stdin = stdin();
let stdin = stdin.lock();
let token: String = stdin
.bytes()
.map(|c| c.expect("failed to read char") as char)
.skip_while(|c| c.is_whitespace())
.take_while(|c| !c.is_whitespace())
.collect();
token.parse().ok().expect("failed to parse token")
}
pub const MOD: u64 = 10e9 as u64 + 7;
pub fn is_prime(n: i32) -> bool {
if n < 2 {
return false;
} else if n == 2 {
return true;
}
let mut i = 2;
while i * i < n {
if n % i == 0 {
return false;
} else {
i += 1;
continue;
}
}
true
}
pub fn lcm(mut n: i32, mut m: i32) -> i32 {
n = if n > m { m } else { n };
m = if n > m { n } else { m };
let mut i = n;
while i % m != 0 {
i += n;
}
i
}
pub fn abs(n: i32) -> i32 {
if n >= 0 {
n
} else {
-n
}
}
pub fn max(n: i32, m: i32) -> i32 {
if n >= m {
n
} else {
m
}
}
pub fn min(n: i32, m: i32) -> i32 {
if n <= m {
n
} else {
m
}
} | Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s019675080 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | def fib(n):
a, b = 2, 1
for i in range(n):
a, b = b, a+b
print(b)
fib(int(input())-1) | Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s816388091 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | n = int(input())
l_i_1 = 2
l_i_2 = 1
while n >= 2:
l_i = l_i_1 + l_i_2
n -= 1
l_i_1 = l_i_2
l_i_2 = l_i
print(l_i)
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s183915644 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | N= int(input())
L=[0]*(N+1)
a=2
b=1
for i in range(1,N+1):
L[0]=2
L[1]=1
L[i]=L[i-1]+L[i-2]
print(L[N]) | Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s583190933 | Wrong Answer | p03544 | Input is given from Standard Input in the following format:
N | n = int(input())
pre2 = 2
pre1 = 1
for i in range(1, n - 1):
tmp = pre2 + pre1
pre2 = pre1
pre1 = tmp
print(pre1 + pre2)
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s447995670 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | t=[0,1]
for i in range(2,90):
t.append(t[i-1]+t[i-2])
print(t(int(input()) | Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s526942273 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | l=[2,1]
for i in range(85):
l.append(l[-1]+l[-2])
n=int(input | Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s271171993 | Wrong Answer | p03544 | Input is given from Standard Input in the following format:
N | print(
[
2,
1,
3,
4,
7,
11,
18,
29,
47,
76,
123,
199,
322,
521,
843,
1364,
2207,
3571,
5778,
9349,
15127,
24476,
39603,
64079,
103682,
167761,
271443,
439204,
710647,
1149851,
1860498,
3010349,
4870847,
7881196,
12752043,
20633239,
33385282,
54018521,
87403803,
141422324,
228826127,
370248451,
599074578,
969323029,
1568397607,
2537720636,
4106118243,
6643838879,
10749957122,
17393796001,
28143753123,
45537549124,
73681302247,
119218851371,
192900153618,
312119004989,
505019158607,
817138163596,
1322157322203,
2139295485799,
3461452808002,
5600748293801,
9062201101803,
14662949395604,
23725150497407,
38388099893011,
62113250390418,
100501350283429,
162614600673847,
263115950957276,
425730551631123,
688846502588399,
1114577054219522,
1803423556807921,
2918000611027443,
4721424167835364,
7639424778862807,
12360848946698171,
20000273725560978,
32361122672259149,
52361396397820127,
84722519070079276,
137083915467899403,
221806434537978679,
358890350005878082,
580696784543856761,
][int(input()) - 1]
)
| Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the N-th Lucas number.
* * * | s500903731 | Runtime Error | p03544 | Input is given from Standard Input in the following format:
N | N = int(input())
L = = [2, 1]
for i in range(87):
L.append(L[i]+L[i+1])
print(L[N]) | Statement
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas
numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
* L_0=2
* L_1=1
* L_i=L_{i-1}+L_{i-2} (i≥2) | [{"input": "5", "output": "11\n \n\n * L_0=2\n * L_1=1\n * L_2=L_0+L_1=3\n * L_3=L_1+L_2=4\n * L_4=L_2+L_3=7\n * L_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\n* * *"}, {"input": "86", "output": "939587134549734843"}] |
Print the smallest sub-array size in a line. | s649779716 | Wrong Answer | p02355 | The input is given in the following format.
$N$ $K$
$a_1$ $a_2$ ... $a_N$ | n, k = map(int, input().split())
aa = list(map(int, input().split()))
cnts = [0] * (k + 1)
ans = 1e6
existing = 0
r = 0
for l in range(n - k):
while r < n and existing < k:
a = aa[r]
if a <= k:
cnts[a] += 1
if cnts[a] == 1:
existing += 1
r += 1
ans = min(ans, r - l)
a = aa[l]
if a <= k:
cnts[a] -= 1
if cnts[a] == 0:
existing -= 1
print(ans if ans < 1e6 else 0)
| The Smallest Window II
For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and an integer
$K$, find the smallest sub-array size (smallest window length) where the
elements in the sub-array contains all integers in range [$1, 2, ..., K$]. If
there is no such sub-array, report 0. | [{"input": "6 2\n 4 1 2 1 3 5", "output": "2"}, {"input": "6 3\n 4 1 2 1 3 5", "output": "3"}, {"input": "3 4\n 1 2 3", "output": "0"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s636361443 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | n = int(input())
a = [int(x) for x in input().split()]
c = [0] * n
for e in a:
c[e - 1] += 1
for e in c:
print(e)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s008543164 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | N, K = map(int, input().split())
if K == N + 1:
print(1)
elif K == N:
print(N + 2)
else:
zentori = []
for i in range(1, 2 ** (N + 1)):
baai = []
for j in range(N + 1):
if (i >> j) & 1:
baai.append(j)
if len(baai) >= K:
zentori.append((sum(baai), len(baai)))
setzentori = set(zentori)
print(int(len(setzentori) % (10**9 + 7)))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s682530849 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | print(int(input) * 3.1415 * 2)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s161456651 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | print(6.28318530717958623200 * int(input()))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s273560932 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | print(2 * 3.14159 * int(input()))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s351478916 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | print(int(input()) * 3.14159265359 * 2)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s178457822 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | print(int(input()) * 3.141592 * 2)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s952261384 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | print(int(input()) * 3.141592)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s492841328 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | print("A" if input().isupper() else "a")
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s488594402 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | pi = 3.1415926535
r = int(input(""), 10)
print(pi * (2 * r))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s465380016 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | print(int(input()) * 3.1415926535)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s736445339 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | print(2 * 3.141592653589793238462643383279502884197169399375 * int(input()))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s321880622 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | R = int(input().rstrip())
print(R * 3.141592653589793238462643383279502884197169399375105820974944592307816406)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s455632255 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | print(int(input()) * 2 * 3.14159265)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s710689156 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | R = input(int())
R = R * 2 * (22 / 7)
print(R, end="")
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s750176988 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | 3
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s747139534 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | A = int(input())
print(A * 3.141)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s925124901 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | n = int(input("enter :"))
print(2 * n * 3.14)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s781621661 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | R = 1
pi = 3.14
Circumference = 2 * R * pi
print(Circumference)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s608425361 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | print(2 * int(input() * 3.141592653589))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s483370699 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | print(3.14 * int(input()))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s628530970 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | num_sub = int(input())
sub_boss = input().split()
num_boss = [0] * (num_sub)
for i in sub_boss:
i = int(i)
num_boss[i - 1] = num_boss[i - 1] + 1
print("\n".join(map(str, num_boss)))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s397680624 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | n = int(input())
s = list(map(int, input().split()))
l = [0] * n
for i in range(n - 1):
l[s[i] - 1] += 1
for _ in range(n):
print(l[_])
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s145755561 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | R = float(input("とりま入れてみ?"))
P = 3.1415
answer = R * R * P
print(answer)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s705288697 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | print(int(input()) * 22 / 7)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s415492727 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | print(3.141 * int(input()))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s477793685 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | print(2 * 3.14159265358979 * int(input()))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s702308536 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | print(int(input()) * 44 / 7)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.