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 2^N-1 lines. In the i-th line, print the answer of the problem above for
K=i.
* * *
|
s408658446
|
Wrong Answer
|
p03313
|
Input is given from Standard Input in the following format:
N
A_0 A_1 ... A_{2^N-1}
|
print("I cannot solve this.")
|
Statement
There is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note
that the sequence is 0-indexed.)
For every integer K satisfying 1 \leq K \leq 2^N-1, solve the following
problem:
* Let i and j be integers. Find the maximum value of A_i + A_j where 0 \leq i < j \leq 2^N-1 and (i or j) \leq K. Here, or denotes the bitwise OR.
|
[{"input": "2\n 1 2 3 1", "output": "3\n 4\n 5\n \n\nFor K=1, the only possible pair of i and j is (i,j)=(0,1), so the answer is\nA_0+A_1=1+2=3.\n\nFor K=2, the possible pairs of i and j are (i,j)=(0,1),(0,2). When\n(i,j)=(0,2), A_i+A_j=1+3=4. This is the maximum value, so the answer is 4.\n\nFor K=3, the possible pairs of i and j are\n(i,j)=(0,1),(0,2),(0,3),(1,2),(1,3),(2,3) . When (i,j)=(1,2), A_i+A_j=2+3=5.\nThis is the maximum value, so the answer is 5.\n\n* * *"}, {"input": "3\n 10 71 84 33 6 47 23 25", "output": "81\n 94\n 155\n 155\n 155\n 155\n 155\n \n\n* * *"}, {"input": "4\n 75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32", "output": "101\n 120\n 147\n 156\n 156\n 178\n 194\n 194\n 194\n 194\n 194\n 194\n 194\n 194\n 194"}]
|
Print 2^N-1 lines. In the i-th line, print the answer of the problem above for
K=i.
* * *
|
s662034749
|
Runtime Error
|
p03313
|
Input is given from Standard Input in the following format:
N
A_0 A_1 ... A_{2^N-1}
|
a = int(input())
ar = list(map(int, input().split(" ")))
print(ar[0] + ar[1])
if ar[0] + ar[1] >= ar[0] + ar[2]:
print(ar[0] + ar[1])
else:
print(ar[0] + ar[2])
br = sorted([ar[0], ar[1], ar[2]])
k = br[2]
g = br[1]
for i in range(3, len(ar)):
if ar[i] > k:
k, g = ar[i], k
elif ar[i] > g:
g = ar[i]
print(k + g)
|
Statement
There is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note
that the sequence is 0-indexed.)
For every integer K satisfying 1 \leq K \leq 2^N-1, solve the following
problem:
* Let i and j be integers. Find the maximum value of A_i + A_j where 0 \leq i < j \leq 2^N-1 and (i or j) \leq K. Here, or denotes the bitwise OR.
|
[{"input": "2\n 1 2 3 1", "output": "3\n 4\n 5\n \n\nFor K=1, the only possible pair of i and j is (i,j)=(0,1), so the answer is\nA_0+A_1=1+2=3.\n\nFor K=2, the possible pairs of i and j are (i,j)=(0,1),(0,2). When\n(i,j)=(0,2), A_i+A_j=1+3=4. This is the maximum value, so the answer is 4.\n\nFor K=3, the possible pairs of i and j are\n(i,j)=(0,1),(0,2),(0,3),(1,2),(1,3),(2,3) . When (i,j)=(1,2), A_i+A_j=2+3=5.\nThis is the maximum value, so the answer is 5.\n\n* * *"}, {"input": "3\n 10 71 84 33 6 47 23 25", "output": "81\n 94\n 155\n 155\n 155\n 155\n 155\n \n\n* * *"}, {"input": "4\n 75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32", "output": "101\n 120\n 147\n 156\n 156\n 178\n 194\n 194\n 194\n 194\n 194\n 194\n 194\n 194\n 194"}]
|
Print 2^N-1 lines. In the i-th line, print the answer of the problem above for
K=i.
* * *
|
s930801174
|
Wrong Answer
|
p03313
|
Input is given from Standard Input in the following format:
N
A_0 A_1 ... A_{2^N-1}
|
def suan(x, y):
li = []
for a in x:
for b in y:
if x[0] == x[1]:
li.append(a + b)
elif a != b:
li.append(a + b)
return max(li)
while True:
try:
n = int(input())
num = list(map(int, input().split()))
maxn = [[num[0], 0]]
max1 = num[0]
max2 = 0
for i in range(1, 2**n):
if num[i] > max2:
max2 = num[i]
if max2 > max1:
max1, max2 = max2, max1
maxn.append([max1, max2])
for i in range(1, 2**n):
xxx = []
if (i | (i - 1)) <= i:
xxx.append(suan(maxn[i], maxn[i - 1]))
if (i | (i - 2)) <= i and i >= 2:
xxx.append(suan(maxn[i], maxn[i - 2]))
if ((i - 1) | (i - 2)) <= i and i >= 2:
xxx.append(suan(maxn[i - 1], maxn[i - 2]))
print(max(xxx))
except:
break
|
Statement
There is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note
that the sequence is 0-indexed.)
For every integer K satisfying 1 \leq K \leq 2^N-1, solve the following
problem:
* Let i and j be integers. Find the maximum value of A_i + A_j where 0 \leq i < j \leq 2^N-1 and (i or j) \leq K. Here, or denotes the bitwise OR.
|
[{"input": "2\n 1 2 3 1", "output": "3\n 4\n 5\n \n\nFor K=1, the only possible pair of i and j is (i,j)=(0,1), so the answer is\nA_0+A_1=1+2=3.\n\nFor K=2, the possible pairs of i and j are (i,j)=(0,1),(0,2). When\n(i,j)=(0,2), A_i+A_j=1+3=4. This is the maximum value, so the answer is 4.\n\nFor K=3, the possible pairs of i and j are\n(i,j)=(0,1),(0,2),(0,3),(1,2),(1,3),(2,3) . When (i,j)=(1,2), A_i+A_j=2+3=5.\nThis is the maximum value, so the answer is 5.\n\n* * *"}, {"input": "3\n 10 71 84 33 6 47 23 25", "output": "81\n 94\n 155\n 155\n 155\n 155\n 155\n \n\n* * *"}, {"input": "4\n 75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32", "output": "101\n 120\n 147\n 156\n 156\n 178\n 194\n 194\n 194\n 194\n 194\n 194\n 194\n 194\n 194"}]
|
Print 2^N-1 lines. In the i-th line, print the answer of the problem above for
K=i.
* * *
|
s392974320
|
Accepted
|
p03313
|
Input is given from Standard Input in the following format:
N
A_0 A_1 ... A_{2^N-1}
|
def examC():
ans = 0
print(ans)
return
def examD():
ans = 0
print(ans)
return
# 参考
# https://qiita.com/Euglenese/items/260f9ddf513f772d7e42
def examE():
N = I()
A = LI()
n = len(A)
dp = [[0, 0] for _ in range(n)]
for i, a in enumerate(A):
dp[i][0] = a
for j in range(N):
for i, a in enumerate(A):
if i & (1 << j) > 0:
dp[i] = sorted(dp[i & ~(1 << j)] + dp[i], reverse=True)[:2]
ans = 0
for v in dp[1:]:
ans = max(ans, sum(v))
print(ans)
return
def examF():
ans = 0
print(ans)
return
from decimal import getcontext, Decimal as dec
import sys, bisect, itertools, heapq, math, random
from copy import deepcopy
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I():
return int(input())
def LI():
return list(map(int, sys.stdin.readline().split()))
def DI():
return dec(input())
def LDI():
return list(map(dec, sys.stdin.readline().split()))
def LSI():
return list(map(str, sys.stdin.readline().split()))
def LS():
return sys.stdin.readline().split()
def SI():
return sys.stdin.readline().strip()
global mod, mod2, inf, alphabet, _ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord("a") + i) for i in range(26)]
alphabet_convert = {chr(ord("a") + i): i for i in range(26)}
getcontext().prec = 28
sys.setrecursionlimit(10**7)
if __name__ == "__main__":
examE()
"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""
|
Statement
There is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note
that the sequence is 0-indexed.)
For every integer K satisfying 1 \leq K \leq 2^N-1, solve the following
problem:
* Let i and j be integers. Find the maximum value of A_i + A_j where 0 \leq i < j \leq 2^N-1 and (i or j) \leq K. Here, or denotes the bitwise OR.
|
[{"input": "2\n 1 2 3 1", "output": "3\n 4\n 5\n \n\nFor K=1, the only possible pair of i and j is (i,j)=(0,1), so the answer is\nA_0+A_1=1+2=3.\n\nFor K=2, the possible pairs of i and j are (i,j)=(0,1),(0,2). When\n(i,j)=(0,2), A_i+A_j=1+3=4. This is the maximum value, so the answer is 4.\n\nFor K=3, the possible pairs of i and j are\n(i,j)=(0,1),(0,2),(0,3),(1,2),(1,3),(2,3) . When (i,j)=(1,2), A_i+A_j=2+3=5.\nThis is the maximum value, so the answer is 5.\n\n* * *"}, {"input": "3\n 10 71 84 33 6 47 23 25", "output": "81\n 94\n 155\n 155\n 155\n 155\n 155\n \n\n* * *"}, {"input": "4\n 75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32", "output": "101\n 120\n 147\n 156\n 156\n 178\n 194\n 194\n 194\n 194\n 194\n 194\n 194\n 194\n 194"}]
|
Print a floating number denoting the answer. The relative or absolute error of
your answer should not be higher than 10^{-9}.
* * *
|
s345741138
|
Wrong Answer
|
p03939
|
The input is given from Standard Input in the following format:
N d_1 x
|
memo = {0: 0}
def left(s, i):
hall_i = i
while s & 1 << hall_i:
hall_i -= 1
return balls[i] - halls[hall_i]
def right(s, i):
hall_i = i + 1
while s & 1 << hall_i:
hall_i += 1
return halls[hall_i] - balls[i]
def solve(s):
# print(('solve {0:0' + str(N) + 'b}').format(s))
if s not in memo:
ans = 0
cnt = 0
for i in range(N + 1):
if s & 1 << i:
sp = s ^ 1 << i
ans += solve(sp) + (left(sp, i) + right(sp, i)) / 2
cnt += 1
memo[s] = ans / cnt
# print(('solve {0:0' + str(N) + 'b}').format(s), '=', memo[s])
return memo[s]
N, d1, x = [int(x) for x in input().split()]
intervals = [d1 + i * x for i in range(N * 2)]
balls = [d1]
for i in range(1, N):
balls.append(balls[-1] + intervals[2 * i - 1] + intervals[2 * i])
halls = [0]
for i in range(N):
halls.append(halls[-1] + intervals[2 * i] + intervals[2 * i + 1])
for i in range((1 << N) - 1):
solve(i)
print(solve((1 << N) - 1))
|
Statement
There are N balls and N+1 holes in a line. Balls are numbered 1 through N from
left to right. Holes are numbered 1 through N+1 from left to right. The i-th
ball is located between the i-th hole and (i+1)-th hole. We denote the
distance between neighboring items (one ball and one hole) from left to right
as d_i (1 \leq i \leq 2 \times N). You are given two parameters d_1 and x. d_i
- d_{i-1} is equal to x for all i (2 \leq i \leq 2 \times N).
We want to push all N balls into holes one by one. When a ball rolls over a
hole, the ball will drop into the hole if there is no ball in the hole yet.
Otherwise, the ball will pass this hole and continue to roll. (In any scenario
considered in this problem, balls will never collide.)
In each step, we will choose one of the remaining balls uniformly at random
and then choose a direction (either left or right) uniformly at random and
push the ball in this direction. Please calculate the expected total distance
rolled by all balls during this process.
For example, when N = 3, d_1 = 1, and x = 1, the following is one possible
scenario:

* first step: push the ball numbered 2 to its left, it will drop into the hole numbered 2. The distance rolled is 3.
* second step: push the ball numbered 1 to its right, it will pass the hole numbered 2 and drop into the hole numbered 3. The distance rolled is 9.
* third step: push the ball numbered 3 to its right, it will drop into the hole numbered 4. The distance rolled is 6.
So the total distance in this scenario is 18.
Note that in all scenarios every ball will drop into some hole and there will
be a hole containing no ball in the end.
|
[{"input": "1 3 3", "output": "4.500000000000000\n \n\nThe distance between the only ball and the left hole is 3 and distance between\nthe only ball and the right hole is 6. There are only two scenarios (i.e. push\nleft and push right). The only ball will roll 3 and 6 unit distance,\nrespectively. So the answer for this example is (3+6)/2 = 4.5.\n\n* * *"}, {"input": "2 1 0", "output": "2.500000000000000\n \n\n* * *"}, {"input": "1000 100 100", "output": "649620280.957660079002380"}]
|
Print a floating number denoting the answer. The relative or absolute error of
your answer should not be higher than 10^{-9}.
* * *
|
s404808224
|
Runtime Error
|
p03939
|
The input is given from Standard Input in the following format:
N d_1 x
|
import sys
sys.setrecursionlimit(200000)
def solve(n, d, x):
if not n:
return 0
return (
d
+ (2 * n - 1) * x / 2
+ solve(n - 1, ((n + 1) * d + 5 * x / 2) / n, (n + 2) * x / n)
)
print(solve(*map(int, input().split())))
|
Statement
There are N balls and N+1 holes in a line. Balls are numbered 1 through N from
left to right. Holes are numbered 1 through N+1 from left to right. The i-th
ball is located between the i-th hole and (i+1)-th hole. We denote the
distance between neighboring items (one ball and one hole) from left to right
as d_i (1 \leq i \leq 2 \times N). You are given two parameters d_1 and x. d_i
- d_{i-1} is equal to x for all i (2 \leq i \leq 2 \times N).
We want to push all N balls into holes one by one. When a ball rolls over a
hole, the ball will drop into the hole if there is no ball in the hole yet.
Otherwise, the ball will pass this hole and continue to roll. (In any scenario
considered in this problem, balls will never collide.)
In each step, we will choose one of the remaining balls uniformly at random
and then choose a direction (either left or right) uniformly at random and
push the ball in this direction. Please calculate the expected total distance
rolled by all balls during this process.
For example, when N = 3, d_1 = 1, and x = 1, the following is one possible
scenario:

* first step: push the ball numbered 2 to its left, it will drop into the hole numbered 2. The distance rolled is 3.
* second step: push the ball numbered 1 to its right, it will pass the hole numbered 2 and drop into the hole numbered 3. The distance rolled is 9.
* third step: push the ball numbered 3 to its right, it will drop into the hole numbered 4. The distance rolled is 6.
So the total distance in this scenario is 18.
Note that in all scenarios every ball will drop into some hole and there will
be a hole containing no ball in the end.
|
[{"input": "1 3 3", "output": "4.500000000000000\n \n\nThe distance between the only ball and the left hole is 3 and distance between\nthe only ball and the right hole is 6. There are only two scenarios (i.e. push\nleft and push right). The only ball will roll 3 and 6 unit distance,\nrespectively. So the answer for this example is (3+6)/2 = 4.5.\n\n* * *"}, {"input": "2 1 0", "output": "2.500000000000000\n \n\n* * *"}, {"input": "1000 100 100", "output": "649620280.957660079002380"}]
|
Print the value of the maximum integer N such that f(N)=X.
* * *
|
s839975251
|
Accepted
|
p03893
|
The input is given from Standard Input in the following format:
X
|
X = int(input())
ans = 1
for _ in range(X + 1):
ans = 2 * ans + 1
print(ans - 1)
|
Statement
We have a cord whose length is a positive integer. We will perform the
following condition until the length of the cord becomes at most 2:
* Operation: Cut the rope at two positions to obtain three cords, each with a length of a positive integer. Among these, discard one with the longest length and one with the shortest length, and keep the remaining one.
Let f(N) be the maximum possible number of times to perform this operation,
starting with a cord with the length N.
You are given a positive integer X. Find the maximum integer N such that
f(N)=X.
|
[{"input": "2", "output": "14"}]
|
Print the value of the maximum integer N such that f(N)=X.
* * *
|
s797685000
|
Accepted
|
p03893
|
The input is given from Standard Input in the following format:
X
|
g = [None] * 50
h = [None] * 50
h[1] = 3
g[1] = 6
X = int(input())
for i in range(2, X + 1):
h[i] = g[i - 1] + 1
g[i] = 2 * h[i]
print(g[X])
|
Statement
We have a cord whose length is a positive integer. We will perform the
following condition until the length of the cord becomes at most 2:
* Operation: Cut the rope at two positions to obtain three cords, each with a length of a positive integer. Among these, discard one with the longest length and one with the shortest length, and keep the remaining one.
Let f(N) be the maximum possible number of times to perform this operation,
starting with a cord with the length N.
You are given a positive integer X. Find the maximum integer N such that
f(N)=X.
|
[{"input": "2", "output": "14"}]
|
Print the value of the maximum integer N such that f(N)=X.
* * *
|
s128668529
|
Accepted
|
p03893
|
The input is given from Standard Input in the following format:
X
|
x = int(input())
n = 2
for i in range(x):
n = n + n + 1 + 1
print(n)
|
Statement
We have a cord whose length is a positive integer. We will perform the
following condition until the length of the cord becomes at most 2:
* Operation: Cut the rope at two positions to obtain three cords, each with a length of a positive integer. Among these, discard one with the longest length and one with the shortest length, and keep the remaining one.
Let f(N) be the maximum possible number of times to perform this operation,
starting with a cord with the length N.
You are given a positive integer X. Find the maximum integer N such that
f(N)=X.
|
[{"input": "2", "output": "14"}]
|
Print the value of the maximum integer N such that f(N)=X.
* * *
|
s509848668
|
Wrong Answer
|
p03893
|
The input is given from Standard Input in the following format:
X
|
print((4 << int(input()) + 2) - 2)
|
Statement
We have a cord whose length is a positive integer. We will perform the
following condition until the length of the cord becomes at most 2:
* Operation: Cut the rope at two positions to obtain three cords, each with a length of a positive integer. Among these, discard one with the longest length and one with the shortest length, and keep the remaining one.
Let f(N) be the maximum possible number of times to perform this operation,
starting with a cord with the length N.
You are given a positive integer X. Find the maximum integer N such that
f(N)=X.
|
[{"input": "2", "output": "14"}]
|
Print the count.
* * *
|
s279085629
|
Accepted
|
p02781
|
Input is given from Standard Input in the following format:
N
K
|
n = input()
k = int(input())
# nより小さいことが確定しているdp
# dp_0[i][j] := i桁目まで決めて、0でない数字をj個使った時の数字の個数
dp_0 = [[0 for i in range(k + 1)] for j in range(len(n))]
# nより小さいことが確定していないdp
# dp_1[i][j] := i桁目まで決めて、0でない数字をj個使った時の数字の個数。
dp_1 = [[0 for i in range(k + 1)] for j in range(len(n))]
dp_0[0][0] = 1
dp_0[0][1] = int(n[0]) - 1
dp_1[0][1] = 1
for i in range(1, len(n)):
dp_0[i][0] = 1
for j in range(1, k + 1):
# 今回の桁が0でないことを想定
if n[i] != "0":
# 0を使う場合と使わない場合両方考える
# まずは使わない場合
dp_0[i][j] = (
dp_0[i - 1][j - 1] * 9
+ dp_1[i - 1][j - 1] * (int(n[i]) - 1)
+ dp_0[i - 1][j]
+ dp_1[i - 1][j]
)
dp_1[i][j] = dp_1[i - 1][j - 1]
# 0を使う場合。この時はjが変化しない。なぜなら0を使うか
# dp_1の更新は無し。
# なぜなら、今回の桁が0でないことを想定しているため、もうnを超えることはないから
else:
# 今回の桁が0の場合
# dp_1を遷移式に入れない理由は、今回の桁が0だった時は、どんな数字の選び方をしても
# さっきの桁まででnより小さいことが確定しないものが
# 今回の桁の決め方で確定することはないから。
dp_0[i][j] = dp_0[i - 1][j - 1] * 9 + dp_0[i - 1][j]
dp_1[i][j] = dp_1[i - 1][j]
# print(dp_0)
# print(dp_1)
print(dp_0[-1][k] + dp_1[-1][k])
|
Statement
Find the number of integers between 1 and N (inclusive) that contains exactly
K non-zero digits when written in base ten.
|
[{"input": "100\n 1", "output": "19\n \n\nThe following 19 integers satisfy the condition:\n\n * 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\n* * *"}, {"input": "25\n 2", "output": "14\n \n\nThe following 14 integers satisfy the condition:\n\n * 11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\n* * *"}, {"input": "314159\n 2", "output": "937\n \n\n* * *"}, {"input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n 3", "output": "117879300"}]
|
Print the count.
* * *
|
s420607127
|
Accepted
|
p02781
|
Input is given from Standard Input in the following format:
N
K
|
import sys
from io import StringIO
import unittest
import os
# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)
# DPの対象配列の先頭に0を追加(先頭を0桁目、でなく1桁目、として可読性を上げる)
# さらに、入力を1文字ずつ分けて、数値型でリストに格納する。
def get_dp_target(string: str) -> []:
return [0] + list(map(int, list(string)))
# 実装を行う関数
def resolve(test_def_name=""):
try:
# ※DP対象は以下の関数で取得※
n = get_dp_target(input())
target = int(input())
# ---------------------------------
# DP準備
# ---------------------------------
# DP配列作成※問題ごとに変える※
dp = [[[0 for _ in range(101)] for _ in range(2)] for _ in range(len(n) + 1)]
# DP準備(1桁目の設定)※0も処理するので1桁目の値+1回ループ
for i in range(n[1] + 1):
# 未満フラグ設定
is_smaller = True if i < n[1] else False
# ※問題ごとに変える※
# dp[1][is_smaller][?] = ? というイメージは同じ。
not_zero_count = 0 if i == 0 else 1
dp[1][is_smaller][not_zero_count] += 1
# ---------------------------------
# DP(2桁目以降を処理する) ※ポイント:各ループの回数はDP配列の要素数と同じ。
for place in range(2, len(n)):
# 未満フラグの全パターンループ(2種類しかないが・・)
for is_smaller in range(2):
# 0以外の出現回数ループ(DPの兼ね合い上、範囲は0~100でOK)
for not_zero_count in range(100):
# 値ループ
val_range = 10 if is_smaller else n[place] + 1
for val in range(val_range):
# 値によるフラグ変動
work_is_smaller = is_smaller or val < n[place]
work_not_zero_count = (
not_zero_count if val == 0 else not_zero_count + 1
)
dp[place][work_is_smaller][work_not_zero_count] += dp[
place - 1
][is_smaller][not_zero_count]
print(dp[len(n) - 1][0][target] + dp[len(n) - 1][1][target])
except IndexError as err:
print("インデックスエラー:", err.args[0])
# テストクラス
class TestClass(unittest.TestCase):
def assertIO(self, assert_input, output):
stdout, sat_in = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
resolve(sys._getframe().f_back.f_code.co_name)
sys.stdout.seek(0)
out = sys.stdout.read()[:-1]
sys.stdout, sys.stdin = stdout, sat_in
self.assertEqual(out, output)
def test_input_1(self):
test_input = """100
1"""
output = """19"""
self.assertIO(test_input, output)
def test_input_2(self):
test_input = """25
2"""
output = """14"""
self.assertIO(test_input, output)
def test_input_3(self):
test_input = """314159
2"""
output = """937"""
self.assertIO(test_input, output)
def test_input_4(self):
test_input = """9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
3"""
output = """117879300"""
self.assertIO(test_input, output)
# 自作テストパターン
def test_original(self):
pass
# 実装orテストの呼び出し
if __name__ == "__main__":
if os.environ.get("USERNAME") is None:
# AtCoder提出時の場合
resolve()
else:
# 自PCの場合
unittest.main()
|
Statement
Find the number of integers between 1 and N (inclusive) that contains exactly
K non-zero digits when written in base ten.
|
[{"input": "100\n 1", "output": "19\n \n\nThe following 19 integers satisfy the condition:\n\n * 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\n* * *"}, {"input": "25\n 2", "output": "14\n \n\nThe following 14 integers satisfy the condition:\n\n * 11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\n* * *"}, {"input": "314159\n 2", "output": "937\n \n\n* * *"}, {"input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n 3", "output": "117879300"}]
|
Print the count.
* * *
|
s466041430
|
Accepted
|
p02781
|
Input is given from Standard Input in the following format:
N
K
|
from collections import defaultdict as dd
N = int(input())
K = int(input())
s = str(N)
dp = dd(int)
dp[(True, 1)] = 1
dp[(False, 1)] = int(s[0]) - 1
dp[(False, 0)] = 1
for c in s[1:]:
i = int(c)
ndp = {}
if i != 0:
ndp[(True, 0)] = 0
ndp[(True, 1)] = dp[(True, 0)]
ndp[(True, 2)] = dp[(True, 1)]
ndp[(True, 3)] = dp[(True, 2)]
ndp[(False, 0)] = dp[(False, 0)] + dp[(True, 0)]
ndp[(False, 1)] = (
dp[(False, 1)]
+ dp[(False, 0)] * 9
+ dp[(True, 0)] * (i - 1)
+ dp[(True, 1)]
)
ndp[(False, 2)] = (
dp[(False, 2)]
+ dp[(False, 1)] * 9
+ dp[(True, 1)] * (i - 1)
+ dp[(True, 2)]
)
ndp[(False, 3)] = (
dp[(False, 3)]
+ dp[(False, 2)] * 9
+ dp[(True, 2)] * (i - 1)
+ dp[(True, 3)]
)
else:
ndp[(True, 0)] = dp[(True, 0)]
ndp[(True, 1)] = dp[(True, 1)]
ndp[(True, 2)] = dp[(True, 2)]
ndp[(True, 3)] = dp[(True, 3)]
ndp[(False, 0)] = dp[(False, 0)]
ndp[(False, 1)] = dp[(False, 1)] + dp[(False, 0)] * 9
ndp[(False, 2)] = dp[(False, 2)] + dp[(False, 1)] * 9
ndp[(False, 3)] = dp[(False, 3)] + dp[(False, 2)] * 9
dp = ndp
print(dp[True, K] + dp[False, K])
|
Statement
Find the number of integers between 1 and N (inclusive) that contains exactly
K non-zero digits when written in base ten.
|
[{"input": "100\n 1", "output": "19\n \n\nThe following 19 integers satisfy the condition:\n\n * 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\n* * *"}, {"input": "25\n 2", "output": "14\n \n\nThe following 14 integers satisfy the condition:\n\n * 11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\n* * *"}, {"input": "314159\n 2", "output": "937\n \n\n* * *"}, {"input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n 3", "output": "117879300"}]
|
Print the count.
* * *
|
s956441043
|
Wrong Answer
|
p02781
|
Input is given from Standard Input in the following format:
N
K
|
n = int(input())
k = int(input())
start = int("1" * k)
i = start
inc = 10 ** (k - 1)
x = 1
r = 0
lst = []
while i <= n:
lst.append(i)
i += inc
x += 1
if x == 10:
x = 0
inc = 10 ** (k - r)
r -= 1
print(len(lst))
|
Statement
Find the number of integers between 1 and N (inclusive) that contains exactly
K non-zero digits when written in base ten.
|
[{"input": "100\n 1", "output": "19\n \n\nThe following 19 integers satisfy the condition:\n\n * 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\n* * *"}, {"input": "25\n 2", "output": "14\n \n\nThe following 14 integers satisfy the condition:\n\n * 11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\n* * *"}, {"input": "314159\n 2", "output": "937\n \n\n* * *"}, {"input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n 3", "output": "117879300"}]
|
Print the count.
* * *
|
s966364938
|
Wrong Answer
|
p02781
|
Input is given from Standard Input in the following format:
N
K
|
print(0)
|
Statement
Find the number of integers between 1 and N (inclusive) that contains exactly
K non-zero digits when written in base ten.
|
[{"input": "100\n 1", "output": "19\n \n\nThe following 19 integers satisfy the condition:\n\n * 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\n* * *"}, {"input": "25\n 2", "output": "14\n \n\nThe following 14 integers satisfy the condition:\n\n * 11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\n* * *"}, {"input": "314159\n 2", "output": "937\n \n\n* * *"}, {"input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n 3", "output": "117879300"}]
|
Print the count.
* * *
|
s437534335
|
Wrong Answer
|
p02781
|
Input is given from Standard Input in the following format:
N
K
|
n = int(input())
l = len(str(n))
k = int(input())
dp = [[[0] * (k + 1) for _ in range(2)] for _ in range(l + 1)]
dp[0][1][0] = 1
for pos in range(l):
num = int(str(n)[pos])
for i in range(10):
if i == 0:
for count in range(k + 1):
dp[pos + 1][0][count] += dp[pos][0][count] + dp[pos][1][count]
elif i < num:
for count in range(k):
dp[pos + 1][0][count + 1] += dp[pos][0][count] + dp[pos][1][count]
elif i == num:
for count in range(k):
dp[pos + 1][1][count + 1] += dp[pos][1][count]
dp[pos + 1][0][count + 1] += dp[pos][0][count]
else:
for count in range(k):
dp[pos + 1][0][count + 1] += dp[pos][0][count]
print(dp[l][0][k] + dp[l][1][k])
|
Statement
Find the number of integers between 1 and N (inclusive) that contains exactly
K non-zero digits when written in base ten.
|
[{"input": "100\n 1", "output": "19\n \n\nThe following 19 integers satisfy the condition:\n\n * 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\n* * *"}, {"input": "25\n 2", "output": "14\n \n\nThe following 14 integers satisfy the condition:\n\n * 11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\n* * *"}, {"input": "314159\n 2", "output": "937\n \n\n* * *"}, {"input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n 3", "output": "117879300"}]
|
Print the count.
* * *
|
s483071217
|
Accepted
|
p02781
|
Input is given from Standard Input in the following format:
N
K
|
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = sr()
K = ir()
length = len(N)
top = int(N[0])
dp_dec = [[0] * 4 for _ in range(length)] # decided
dp_pen = [[0] * 4 for _ in range(length)] # pending
dp_dec[0][1] = top - 1
dp_dec[0][0] = 1
dp_pen[0][1] = 1
for i in range(1, length):
cur = int(N[i])
if cur == 0:
dp_pen[i] = dp_pen[i - 1][:] # 右端に0
else:
for k in range(1, 4):
dp_pen[i][k] = dp_pen[i - 1][k - 1] # 右端にcur
dp_dec[i] = dp_dec[i - 1][:] # 0が右端に加わった場合
for j in range(1, 4):
dp_dec[i][j] += dp_dec[i - 1][j - 1] * 9 # 1~9が右端に加わった場合
if cur > 0:
dp_dec[i][j] += (
dp_pen[i - 1][j - 1] * (cur - 1) + dp_pen[i - 1][j] * 1
) # 右端にcur以下の数が加わった場合と0が加わった場合
answer = dp_dec[length - 1][K] + dp_pen[length - 1][K]
print(answer)
|
Statement
Find the number of integers between 1 and N (inclusive) that contains exactly
K non-zero digits when written in base ten.
|
[{"input": "100\n 1", "output": "19\n \n\nThe following 19 integers satisfy the condition:\n\n * 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\n* * *"}, {"input": "25\n 2", "output": "14\n \n\nThe following 14 integers satisfy the condition:\n\n * 11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\n* * *"}, {"input": "314159\n 2", "output": "937\n \n\n* * *"}, {"input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n 3", "output": "117879300"}]
|
Print the count.
* * *
|
s543994985
|
Accepted
|
p02781
|
Input is given from Standard Input in the following format:
N
K
|
n = int(input())
k = int(input())
digit = len(str(n))
# dp[i桁まで検査済み][coincidence][0以外の個数]
dp = [[[0] * (k + 1) for i in range(2)] for j in range(digit + 1)]
dp[0][1][0] = 1
for a in range(1, digit + 1):
digitvalue = int(str(n)[a - 1])
for c in range(k + 1):
if c == k:
# 最大値と不一致で0以外の個数がk個になる
dp[a][0][c] += dp[a - 1][0][k] * 1
dp[a][0][c] += dp[a - 1][0][k - 1] * 9
# d != 0(仮に3) -> 0
# d == 0 -> 0にすると最大値と一致するのでだめ
dp[a][0][c] += dp[a - 1][1][k] * (1 if digitvalue != 0 else 0)
# d != 0(仮に3) -> 1, 2(0はkにならないのでだめ、3はb == 1になるのでだめ)
# d == 0 -> 0にするとkが増えないのでだめ
dp[a][0][c] += dp[a - 1][1][k - 1] * (
digitvalue - 1 if digitvalue != 0 else 0
)
# 最大値と一致で0以外の個数がk個になる
dp[a][1][c] += dp[a - 1][1][k] * (1 if digitvalue == 0 else 0)
dp[a][1][c] += dp[a - 1][1][k - 1] * (1 if digitvalue != 0 else 0)
elif c != k:
# 最大値と不一致で0以外の個数がc個になる
dp[a][0][c] += dp[a - 1][0][c] * 1
dp[a][0][c] += 0 if c == 0 else dp[a - 1][0][c - 1] * 9
dp[a][0][c] += dp[a - 1][1][c] * (1 if digitvalue != 0 else 0)
dp[a][0][c] += (
0
if c == 0
else dp[a - 1][1][c - 1] * (digitvalue - 1 if digitvalue != 0 else 0)
)
dp[a][1][c] += dp[a - 1][1][c] * (1 if digitvalue == 0 else 0)
dp[a][1][c] += (
0 if c == 0 else dp[a - 1][1][c - 1] * (1 if digitvalue != 0 else 0)
)
else:
None
# print("--", a)
# for i in range(k + 1):
# print(dp[a][0][i])
# for i in range(k + 1):
# print(dp[a][1][i])
print(dp[digit][0][k] + dp[digit][1][k])
|
Statement
Find the number of integers between 1 and N (inclusive) that contains exactly
K non-zero digits when written in base ten.
|
[{"input": "100\n 1", "output": "19\n \n\nThe following 19 integers satisfy the condition:\n\n * 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\n* * *"}, {"input": "25\n 2", "output": "14\n \n\nThe following 14 integers satisfy the condition:\n\n * 11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\n* * *"}, {"input": "314159\n 2", "output": "937\n \n\n* * *"}, {"input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n 3", "output": "117879300"}]
|
Print the count.
* * *
|
s717347009
|
Accepted
|
p02781
|
Input is given from Standard Input in the following format:
N
K
|
## ABC154E
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
M = 10**9 + 7 # 出力の制限
N = 100 # 必要なテーブルサイズ
def cmb(n, r, M):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return (g1[n] * g2[r] * g2[n - r]) % M
g1 = [None] * (N + 1) # 元テーブル
g2 = [None] * (N + 1) # 逆元テーブル
inverse = [None] * (N + 1) # 逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1]
for i in range(2, N + 1):
g1[i] = (g1[i - 1] * i) % M
inverse[i] = (
-inverse[M % i] * (M // i)
) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
g2[i] = (g2[i - 1] * inverse[i]) % M
n = input()
k = int(input())
l = len(n)
dp0 = [[0] * (k + 1) for _ in range(l + 1)] # i桁目まででNより小さく、非零がjの個数
dp1 = [[0] * (k + 1) for _ in range(l + 1)] # i桁目でNと同じで、非零がjの個数
dp1[0][0] = 1
if k > l:
ans = 0
else:
for i in range(1, l + 1):
for j in range(k + 1):
c = int(n[i - 1])
if j >= 1:
dp0[i][j] += 9 * dp0[i - 1][j - 1]
dp0[i][j] += dp0[i - 1][j]
if c >= 1:
dp0[i][j] += dp1[i - 1][j]
if j >= 1:
dp0[i][j] += (c - 1) * dp1[i - 1][j - 1]
if c == 0:
dp1[i][j] += dp1[i - 1][j]
elif j >= 1:
dp1[i][j] += dp1[i - 1][j - 1]
ans = dp0[l][k] + dp1[l][k]
print(ans)
|
Statement
Find the number of integers between 1 and N (inclusive) that contains exactly
K non-zero digits when written in base ten.
|
[{"input": "100\n 1", "output": "19\n \n\nThe following 19 integers satisfy the condition:\n\n * 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\n* * *"}, {"input": "25\n 2", "output": "14\n \n\nThe following 14 integers satisfy the condition:\n\n * 11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\n* * *"}, {"input": "314159\n 2", "output": "937\n \n\n* * *"}, {"input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n 3", "output": "117879300"}]
|
Print the count.
* * *
|
s675165881
|
Accepted
|
p02781
|
Input is given from Standard Input in the following format:
N
K
|
N = input()
K = int(input())
m = len(N)
a = 0
if K == 3:
for i in range(1, m - 2):
a += i * (i + 1)
a //= 2
a *= 729
for i in range(1, 10):
for j in range(1, 10):
for k in range(1, 10):
for b in range(m - 2):
for c in range(m - 2 - b):
if N >= str(i) + "0" * b + str(j) + "0" * c + str(k) + "0" * (
m - 3 - b - c
):
a += 1
elif K == 1:
if int(N) < 10:
a = int(N)
else:
a = 9
for i in range(2, m):
a += 9
for i in range(1, 10):
if N >= str(i) + "0" * (m - 1):
a += 1
else:
for i in range(1, m - 1):
a += i
a *= 81
for i in range(1, 10):
for j in range(1, 10):
for k in range(m - 1):
if N >= str(i) + "0" * k + str(j) + "0" * (m - 2 - k):
a += 1
print(a)
|
Statement
Find the number of integers between 1 and N (inclusive) that contains exactly
K non-zero digits when written in base ten.
|
[{"input": "100\n 1", "output": "19\n \n\nThe following 19 integers satisfy the condition:\n\n * 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\n* * *"}, {"input": "25\n 2", "output": "14\n \n\nThe following 14 integers satisfy the condition:\n\n * 11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\n* * *"}, {"input": "314159\n 2", "output": "937\n \n\n* * *"}, {"input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n 3", "output": "117879300"}]
|
Print the count.
* * *
|
s972991693
|
Accepted
|
p02781
|
Input is given from Standard Input in the following format:
N
K
|
# 桁DPは、
# 「0以上N以下の整数で、ある条件を満たすものの個数を求めよ」
# 「0以上N以下の整数で、ある条件を満たすものの最大値を求めよ」
# といった問題を解く場合に用いられる方法です。
# https://qiita.com/pinokions009/items/1e98252718eeeeb5c9ab
n = input()
k_in = int(input())
# dp[i][smaller][k] := 上位からi桁目まで見て、smaller(nと一致しているいない)で非0の桁がk個だけあるものの数
# i <= 101, k <= 3 より、マス目の数は高々606。
# k = 4まで取っておくと(番兵)漸化式の場合分けをしなくて良いから楽。ただしループは
dp = [[[0 for _ in range(4 + 1)] for _ in range(2)] for _ in range(len(n))]
digit = int(n[0])
dp[0][False][0] = 1
dp[0][False][1] = digit - 1
dp[0][True][1] = 1
for i in range(len(n) - 1):
for smaller in [True, False]:
for k in range(4):
# 配るDPのほうが楽そうな予感
if not smaller:
# 0をつけたら
dp[i + 1][False][k] += dp[i][smaller][k]
# 1~9をつけたら
dp[i + 1][False][k + 1] += 9 * dp[i][smaller][k]
else:
next_digit = int(n[i + 1])
if next_digit == 0:
# 0をつけるしかない
dp[i + 1][True][k] += dp[i][smaller][k]
else:
# 0をつけたら
dp[i + 1][False][k] += dp[i][smaller][k]
# 1〜(next_digit - 1)をつけたら
dp[i + 1][False][k + 1] += (next_digit - 1) * dp[i][smaller][k]
# next_digit をつけたら
dp[i + 1][True][k + 1] += dp[i][smaller][k]
print(dp[len(n) - 1][True][k_in] + dp[len(n) - 1][False][k_in])
|
Statement
Find the number of integers between 1 and N (inclusive) that contains exactly
K non-zero digits when written in base ten.
|
[{"input": "100\n 1", "output": "19\n \n\nThe following 19 integers satisfy the condition:\n\n * 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100\n\n* * *"}, {"input": "25\n 2", "output": "14\n \n\nThe following 14 integers satisfy the condition:\n\n * 11,12,13,14,15,16,17,18,19,21,22,23,24,25\n\n* * *"}, {"input": "314159\n 2", "output": "937\n \n\n* * *"}, {"input": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\n 3", "output": "117879300"}]
|
Find the minimum number of operations required to make s equal to t. It can be
proved that the objective is always achievable in a finite number of
operations.
* * *
|
s534387514
|
Runtime Error
|
p03190
|
Input is given from Standard Input in the following format:
N
s
t
|
import numpy as np
N = int(input())
S = np.array(list(map(int, list(input()))), dtype=np.int)
T = np.array(list(map(int, list(input()))), dtype=np.int)
def lessthan3(s, t, N, k, f):
if k >= N:
return 0
elif s[k] == t[k]:
if f == 0:
return lessthan3(s, t, N, k + 1, 0)
elif f == 1:
if k < N - 1:
return lessthan3(s, t, N, k + 1, 2)
else:
s[k] ^= 1
return lessthan3(s, t, N, k, 1) + 1
else:
s[k] ^= 1
return lessthan3(s, t, N, k, 2) + 1
elif (
(k >= 2 and s[k - 1] == t[k] and s[k - 2] == t[k])
or (N - k >= 3 and s[k + 1] == t[k] and s[k + 2] == t[k])
or (k >= 1 and N - k >= 2 and s[k - 1] == t[k] and s[k + 1] == t[k])
):
return lessthan3(s, t, N, k + 1, 1) + 1
# elif f==0:
else:
s[k] = t[k]
return lessthan3(s, t, N, k + 1, 0) + 1
# else:
# return lessthan3(s,t,N,k-f,0)
print(lessthan3(S, T, N, 0, 0))
|
Statement
You are given strings s and t, both of length N. s and t consist of `0` and
`1`. Additionally, in these strings, the same character never occurs three or
more times in a row.
You can modify s by repeatedly performing the following operation:
* Choose an index i (1 \leq i \leq N) freely and invert the i-th character in s (that is, replace `0` with `1`, and `1` with `0`), under the condition that the same character would not occur three or more times in a row in s after the operation.
Your objective is to make s equal to t. Find the minimum number of operations
required.
|
[{"input": "4\n 0011\n 0101", "output": "4\n \n\nOne possible solution is `0011` \u2192 `1011` \u2192 `1001` \u2192 `1101` \u2192 `0101`.\n\n* * *"}, {"input": "1\n 0\n 0", "output": "0\n \n\n* * *"}, {"input": "8\n 00110011\n 10101010", "output": "10"}]
|
Print x rounded up to the nearest integer.
* * *
|
s385990815
|
Accepted
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
ab = input().rstrip().split(" ")
print(int(((int(ab[0]) + int(ab[1])) + 2 - 1) / 2))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s986463918
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
x,y = map(int,input().split())
if (x + y) % == 0:
print((x+y)/2)
else:
print((x+y+1)/2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s982643466
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import math
a, b = map(int, input().split())
mean = (a + b) / 2.0
print(int(math.ceil(mean))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s716980830
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
from math import ceil
a, b = map(int, input().split())
(a + b) / 2 = x
print(ceil(x))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s962059018
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
x,y = map(int,input().split())
if (x + y) % == 0:
print((x+y)/2)
else:
print((x+y+1)/2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s728350680
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import math
a, b = map(int, input().split())
mean = (a + b) / 2
print(int(math.ceil(mean))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s981698615
|
Wrong Answer
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
num_list = map(int, input().split())
sum = 0
for num in num_list:
sum += num
print(sum // 2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s133650661
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import math
a, b = map(int, input().split())
(a + b) / 2 = x
print(ceil(x))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s757407544
|
Accepted
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import sys
## io ##
def IS():
return sys.stdin.readline().rstrip()
def II():
return int(IS())
def MII():
return list(map(int, IS().split()))
def MIIZ():
return list(map(lambda x: x - 1, MII()))
## dp ##
INIT_VAL = 0
def DD2(d1, d2):
return [[INIT_VAL] * d2 for _ in range(d1)]
def DD3(d1, d2, d3):
return [DD2(d2, d3) for _ in range(d1)]
## math ##
MOD = 10**9 + 7
def divc(x, y):
return -(-x // y)
def divf(x, y):
return x // y
def gcd(x, y):
while y:
x, y = y, x % y
return x
def lcm(x, y):
return x * y // gcd(x, y)
def get_primes(MAX_NUM=10**3):
"""Return a list of prime numbers"""
is_prime = [True] * MAX_NUM
is_prime[0] = False
is_prime[1] = False
primes = []
for i in range(MAX_NUM):
if is_prime[i]:
primes.append(i)
for j in range(2 * i, MAX_NUM, i):
is_prime[j] = False
return primes
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
# ======================================================#
def main():
a, b = MII()
print(divc(a + b, 2))
if __name__ == "__main__":
main()
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s860067190
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import collections
import itertools
s = list(map(str, input()))
g = list(map(lambda x: int(x), input().split()))
seq = ("R", "L")
ans = False
count_dict = collections.Counter(s)
g_sum = abs(g[0]) + abs(g[1])
if g_sum > count_dict["F"]:
print("No")
else:
patterns = list(itertools.product(seq, repeat=count_dict["T"]))
for _p in patterns:
i = 0
m = [0, 0]
n = 3
for _s in s:
if _s == "F":
if n == 3:
m[0] = m[0] + 1
elif n == 1:
m[0] = m[0] - 1
elif n == 0:
m[1] = m[1] + 1
elif n == 2:
m[1] = m[1] - 1
else:
i = i + 1
if _p[i - 1] == "R":
if n == 0:
n = 3
else:
n = n - 1
elif _p[i - 1] == "L":
if n == 3:
n = 0
else:
n = n + 1
if m[0] == g[0] and m[1] == g[1]:
ans = True
break
if ans:
print("Yes")
else:
print("No")
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s096891871
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a, b = map(int, input().split())
c = a + b
if c % 2 == 0
print(int(c/2))
else:
print(int(c // 2 + 1))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s673349590
|
Wrong Answer
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI():
return list(map(int, sys.stdin.readline().split()))
def I():
return int(sys.stdin.readline())
def LS():
return list(map(list, sys.stdin.readline().split()))
def S():
return list(sys.stdin.readline())[:-1]
def IR(n):
l = [None for i in range(n)]
for i in range(n):
l[i] = I()
return l
def LIR(n):
l = [None for i in range(n)]
for i in range(n):
l[i] = LI()
return l
def SR(n):
l = [None for i in range(n)]
for i in range(n):
l[i] = S()
return l
def LSR(n):
l = [None for i in range(n)]
for i in range(n):
l[i] = LS()
return l
sys.setrecursionlimit(1000000)
mod = 1000000007
# A
def A():
a, b = LI()
print((a + b) // 2)
return
# B
def B():
s = S()
t = S()
s.sort()
t.sort(reverse=True)
if s < t:
print("Yes")
else:
print("No")
return
# C
def C():
n = I()
d = [None for i in range(n + 1)]
d[0] = 2
d[1] = 1
for i in range(2, n + 1):
d[i] = d[i - 1] + d[i - 2]
print(d[n])
return
# D
def D():
x, y, z = LI()
for i in range(1000000)[::-1]:
if i * y + (i + 1) * z <= x:
print(i)
quit()
return
# E
def E():
d = [(1, 0), (-1, 0), (0, 1), (0, -1)]
h, w = LI()
s = SR(h)
for i in range(h):
for j in range(w):
if s[i][j] == "#":
su = 0
for dy, dx in d:
y = i + dy
x = j + dx
if 0 <= y < h and 0 <= x < w:
if s[y][x] == "#":
su += 1
if su == 0:
print("No")
quit()
print("Yes")
return
# F
def F():
a, b, c, X, Y = LI()
ans = float("inf")
for z in range(300001):
if z % 2 == 0:
m = c * z
x = z // 2
y = z // 2
m += a * max(0, X - x)
m += b * max(0, Y - y)
if m < ans:
ans = m
print(ans)
return
# G
def G():
n = I()
x = LI()
f = [(i, x[i]) for i in range(n)]
f.sort(key=lambda x: x[1])
g = [(f[i][0], i) for i in range(n)]
g.sort(key=lambda x: x[0])
for i in range(n):
if g[i][1] < n // 2:
print(f[n // 2][1])
else:
print(f[n // 2 - 1][1])
return
# H
def H():
return
# I
def I_():
return
# J
def J():
return
# Solve
if __name__ == "__main__":
A()
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s342583453
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a, b = (int(x) for x in input().split())
s = (a + b) % 2
t = (a + b) / 2
if s == 0:
print(t)
else:
print(t + 0.5)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s409306549
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print((lambda x: int((int(x[0]) + int(x[1])) / 2 + 0.999999999999999999999999999999))(input().split())print((lambda x: int(0.999999999999 + ((int(x[0]) + int(x[1])) / 2)))(input().split()))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s619248644
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a,b = map(int,input().split())
if (a + b)%2 ==0:
print(round((a + b) / 2))
else:
print(round((a + b + 1) / 2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s208277822
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y):
return pow(x, y, MOD)
def INV(x, m=MOD):
return pow(x, m - 2, m)
def DIV(x, y, m=MOD):
return (x * INV(y, m)) % m
def LI():
return [int(x) for x in input().split()]
def LF():
return [float(x) for x in input().split()]
def LS():
return input().split()
def II():
return int(sys.stdin.readline())
def SI():
return input()
S = input()
X, Y = LI()
while S and S[0] == "F":
S = S[1:]
X -= 1
isX = True
cur = 0
xs = []
ys = []
for i in range(len(S)):
if S[i] == "T":
if cur:
if isX:
xs.append(cur)
else:
ys.append(cur)
isX = not isX
cur = 0
elif S[i] == "F":
cur += 1
if cur:
if isX:
xs.append(cur)
else:
ys.append(cur)
X = abs(X)
Y = abs(Y)
sumxs = sum(xs)
sumys = sum(ys)
if X > sumxs or Y > sumys:
print("No")
exit()
memo1 = [[0] * (sumxs * 2 + 10) for i in range(len(xs) + 1)]
memo2 = [[0] * (sumys * 2 + 10) for i in range(len(ys) + 1)]
memo1[0][0] = 1
memo2[0][0] = 1
for i in range(1, len(xs) + 1):
for j in range(-sumxs, sumxs + 1):
memo1[i][j] = memo1[i - 1][j + xs[i - 1]]
memo1[i][j] = memo1[i - 1][j - xs[i - 1]]
# print(len(ys))
# print(len(memo2))
for i in range(1, len(ys) + 1):
for j in range(-sumys, sumys + 1):
memo2[i][j] = memo2[i - 1][j + ys[i - 1]]
memo2[i][j] = memo2[i - 1][j - ys[i - 1]]
print("Yes" if memo1[len(xs)][X] and memo2[len(ys)][Y] else "No")
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s332390923
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
n = int(input())
l = list(map(int, input().split()))
L = list(set(l))
count = 0
for x in L:
if l.count(x) == x:
continue
elif l.count(x) > x:
count += l.count(x) - x
else:
count += l.count(x)
print(count)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s034322729
|
Accepted
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a = sum(list(map(int, input().split())))
print(a // 2 if a % 2 == 0 else a // 2 + 1)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s620534630
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import math
a, b = map(int, input().split())
print(int(math.ceil(mean))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s535412386
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s026790036
|
Wrong Answer
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
n, m = map(int, input().split())
print((n + m) // 2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s470307858
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a,b=map(int,input().split())
print((a+b+1)/2))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s302126123
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
N = int(input().rstrip())
numbers = [int(i) for i in input().rstrip().split()]
n_dic = {str(i): 0 for i in set(numbers)}
for i in numbers:
n_dic[str(i)] += 1
count = 0
for i, j in n_dic.items():
if int(i) < j:
count += j - int(i)
elif int(i) > j:
count += j
print(count)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s497064813
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
def compare(a, A):
R = 0
for i in range(0, len(A)):
if a == A[i]:
R += 1
elif a < A[i]:
break
return R
def result(R, a):
if R == a:
return 0
elif a < R:
return R - a
return R
N = int(input())
a = list(map(int, input().split()))
a.sort()
R = 0
T = compare(a[0], a)
R += result(T, a[0])
for i in range(1, N):
if a[i] != a[i - 1]:
C = compare(a[i], a[T:])
R += result(C, a[i])
T += C
print(R)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s850274548
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
s = input()
x, y = list(map(int, input().split()))
dx = []
dy = []
first = True
move = 0
xf = 0
dir = 0
for i in s:
if i == "F":
move += 1
else:
if first:
xf = move
first = False
else:
if dir % 2 == 0:
dx.append(move)
else:
dy.append(move)
dir += 1
move = 0
if dir % 2 == 0:
dx.append(move)
else:
dy.append(move)
cx = 0
cy = 0
x -= xf
for i in sorted(dx, reverse=True):
if x > cx:
cx += i
else:
cx -= i
for i in sorted(dy, reverse=True):
if y > cy:
cy += i
else:
cy -= i
# print(sorted(dx,reverse=True),sorted(dy,reverse=True))
if cx == x and cy == y:
print("Yes")
else:
print("No")
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s083088565
|
Wrong Answer
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
st = input().split()
a = int(st[0])
b = int(st[1])
print(round((a + b) / 2))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s755832213
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print((int(input()) + int(input()) + 1) / 2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s557431760
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
-*- coding: utf-8 -*-
import math
l = rawinput().split()
print(math.ceil(l[0] + l[1])
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s707831692
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a,b = map(int,input().split())
average = (a+b)/2
print(math.ceil(average)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s201271747
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import ceil from math
a, b = map(int, input().split())
print(ceil((a+b)/2))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s098690707
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import math
a, b = map(int, input(), split( ))
print(math.ceil((a * b) / 2))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s192621748
|
Wrong Answer
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print(math.ceil(eval(input().replace(" ", "+")) / 2) for math in [__import__("math")])
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s152475880
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import.math
a,b = map(int, input().split())
print(int(math.ceil((a+b)/2)))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s641279357
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import math
a,b = [int(x) for x in input().split()]
print(math.ceil((a+b)/2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s478762420
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a,b = map(int, input().split())
if (a+b) % 2 = 0:
print(int((a+b)/2))
else:
print(int((a+b)/2)+1)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s277926838
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a, b = map(int, input().split())
ave = (a + b) / 2
if ave - int(ave) > 0:
ave = int(ave) + 1
else
ave = int(ave)
print(ave)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s972198392
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
# -*- coding: utf-8 -*-
b, c = map(int, input().split())
s=0.5*(b+c)
d = int(s)
if s-d != 0:
v=d+1
else :
v=d
print(v)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s337084214
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
#coding: utf-8
N = input().split()
A=int(N[0])
B=int(N[1])
C=int((A+B)/2)
if A=B:
print(A)
else:
print(int(C)+1)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s986105174
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import math
a = list(map(int,input().split()))
c = reduce((lambda x,y: (x+y)/2 ,a)
print(math.cell(c))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s952837504
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
#coding: utf-8
N = input().rstrip()
A=N[0]
B=N[1]
C=int((A+B)/2)
if A==B:
print(A)
else:
print(int(C)+1)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s909362260
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
# -*- coding: utf-8 -*-
b, c = map(int, input().split())
double s =0.5*(b+c)
d =int(s)
v=d+1
print(v)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s116683276
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
#coding: utf-8
N = input().rstrip()
A=int(N[0])
B=int(N[1])
C=int((A+B)/2)
if A=B:
print(A)
else:
print(int(C)+1)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s711246751
|
Accepted
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
num = [int(i) for i in input().split()]
print(-(-(num[0] + num[1]) // 2))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s021775960
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
if (a+b)%2 >> 0;
print((a+b)//2+1)
else:
print((a+b)//2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s308586902
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a, b = map(int, input().split())
print(int((a+b)*o.5+0.9))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s065248242
|
Accepted
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print(eval(input().replace(" ", "+1+")) // 2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s062586660
|
Accepted
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print(~-sum(map(int, input().split())) // 2 + 1)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s224402340
|
Accepted
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print(-(-sum(map(int, input().split())) // 2))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s203068600
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print(-(-sum(int, input(), split)) // 2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s712520520
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
i = lambda: int(input())
print((i() + i() + 1) // 2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s903276151
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a,b=input().split();print(eval(a/b+a%b)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s401229465
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a,b = map(int,input())
print(-int((-a-b)//2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s405127619
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print(-(-sum(int, input(), split())) // 2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s820328273
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print(-((-(input()) // 2)))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s762143534
|
Wrong Answer
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print(sum(map(int, input().split())) // 2 + 1)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s027776076
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print(-((-sum(map(int, input(), split()))) // 2))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s805370895
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print(int((int(input()) + int(input())) / 2))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s675871422
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
s = str(input())
x, y = map(int, input().split())
y = abs(y)
a = 0
b = 0
adjust = 0
forward = 1
flag = "Yes"
for i in range(0, int(len(s))):
if s[i] == "F":
if forward == 1:
a += 1
else:
b += 1
else:
forward *= -1
if s[0] == "F":
adjust = 2
if (x >= 0 and a < x) or (x < 0 and a - adjust < -x):
flag = "No"
x = abs(x)
if a % 2 != x % 2 or b < y or b % 2 != y % 2:
flag = "No"
print(flag)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s832450030
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import math
s = list(input().split("T"))
sn = []
for i in range(len(s)):
sn.append(len(s[i]))
x, y = map(int, input().split(" "))
x = x - sn[0]
snx = []
sny = []
for i in range(2, len(sn), 2):
snx.append(sn[i])
for i in range(1, len(sn), 2):
sny.append(sn[i])
# X軸判定
xflg = 0
ansx = []
prex = [0]
for i in range(len(snx)):
tmpx = set()
for j in prex:
tmpx.add(j + snx[i])
tmpx.add(j - snx[i])
prex = tmpx
if x in tmpx:
xflg = 1
# y軸判定
yflg = 0
prey = [0]
for i in range(len(sny)):
tmpy = set()
for j in prey:
tmpy.add(j + sny[i])
tmpy.add(j - sny[i])
prey = tmpy
if y in tmpy:
yflg = 1
if xflg == 1 and yflg == 1:
print("Yes")
else:
print("No")
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s165309971
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a,b = map(int,input().split())
if (a+b)%2==1:
print((a+b)//@2+1)
else:
print((a+b)//2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s098631141
|
Wrong Answer
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
nums = list(map(int, input().split()))
print(round(sum(nums) / float(len(nums))))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s762621188
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a, b = map(int, input(),split())
c= a+b
if c%2==0:
print(c/2)
else:
print((c+1)/2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s454511347
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import math
a, b = map(int, input(), split( ))
print(math.ceil((a + b) / 2))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s873084154
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a,b = map(int,input().split())
x = (a+b)/2
if (a+b)%2 = 0:
print(int(x))
else :
print(int(x)+1)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s298513235
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
l = list(map(int,input().split()))
s = l[0] + l[1]
if s % 2 = 1:
s = s+ 1
else:
None
print(s // 2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s677158239
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a, b = map(int, input().split())
c = a + b
if c % 2 == 0
print(int(c/2))
else:
print(int(c // 2 + 1))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s193308177
|
Wrong Answer
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
x = eval(input().replace(" ", "+"))
print(x / 2 if x % 2 == 0 else x // 2 + 1)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s656485989
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
import math
a,b=map(int,input().split())
print(math.ceil((a+b)/2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s573604043
|
Accepted
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
ab = map(int, input().split())
print((sum(ab) - 1) // 2 + 1)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s292802732
|
Accepted
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print(-~eval(input().replace(" ", "+")) // 2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s939800533
|
Wrong Answer
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
-~eval(input().replace(" ", "+")) // 2
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s416315106
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print(-(-sum(int, input(), split() // 2)))
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s766072178
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print((sum(map(int,input().split())+1)//2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s917823248
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
print((sum(int(input())) + 1) // 2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s092255626
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a, b = map(int, input().split())
print(-(-(a + b) // 2)
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
Print x rounded up to the nearest integer.
* * *
|
s473017646
|
Runtime Error
|
p03485
|
Input is given from Standard Input in the following format:
a b
|
a, b = input(), input()
print("No" if a >= b else "Yes")
|
Statement
You are given two positive integers a and b. Let x be the average of a and b.
Print x rounded up to the nearest integer.
|
[{"input": "1 3", "output": "2\n \n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest\ninteger, 2.\n\n* * *"}, {"input": "7 4", "output": "6\n \n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest\ninteger, 6.\n\n* * *"}, {"input": "5 5", "output": "5"}]
|
For each query, print "1" or "0".
|
s356660100
|
Accepted
|
p02294
|
The entire input looks like:
q (the number of queries)
1st query
2nd query
...
qth query
Each query consists of integer coordinates of end points of s1 and s2 in the
following format:
xp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
3
0 0 3 0 1 1 2 -1
0 0 3 0 3 1 3 -1
0 0 3 0 3 -2 5 0
output:
1
1
0
"""
import sys
EPS = 1e-9
def cross(a, b):
return a.real * b.imag - a.imag * b.real
def dot(a, b):
return a.real * b.real + a.imag * b.imag
def check_ccw(p0, p1, p2):
# flag = float('inf')
a, b = p1 - p0, p2 - p0
if cross(a, b) > EPS:
# print('COUNTER_CLOCKWISE')
flag = 1
elif cross(a, b) < -1 * EPS:
# print('CLOCKWISE')
flag = -1
elif dot(a, b) < -1 * EPS:
# print('ONLINE_BACK')
flag = 2
elif abs(a) < abs(b):
# print('ONLINE_FRONT')
flag = -2
else:
# print('ON_SEGMENT')
flag = 0
return flag
def check_intersection(_lines):
for line in _lines:
line = tuple(map(int, line))
p0, p1, p2, p3 = (x + y * 1j for x, y in zip(line[::2], line[1::2]))
flag = (check_ccw(p0, p1, p2) * check_ccw(p0, p1, p3) <= 0) and (
check_ccw(p2, p3, p0) * check_ccw(p2, p3, p1) <= 0
)
if flag:
print("1")
else:
print("0")
return None
if __name__ == "__main__":
_input = sys.stdin.readlines()
l_num = int(_input[0])
lines = map(lambda x: x.split(), _input[1:])
check_intersection(lines)
|
Intersection
For given two segments s1 and s2, print "1" if they are intersect, "0"
otherwise.
s1 is formed by end points p0 and p1, and s2 is formed by end points p2 and
p3.
|
[{"input": "3\n 0 0 3 0 1 1 2 -1\n 0 0 3 0 3 1 3 -1\n 0 0 3 0 3 -2 5 0", "output": "1\n 1\n 0"}]
|
For each query, print "1" or "0".
|
s673465195
|
Accepted
|
p02294
|
The entire input looks like:
q (the number of queries)
1st query
2nd query
...
qth query
Each query consists of integer coordinates of end points of s1 and s2 in the
following format:
xp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3
|
import math
EPS = 1e-10
def equals(a, b):
return abs(a - b) < EPS
class Point:
def __init__(self, x=0, y=0):
self.x = x
self.y = y
def __add__(self, p):
return Point(self.x + p.x, self.y + p.y)
def __sub__(self, p):
return Point(self.x - p.x, self.y - p.y)
def __mul__(self, a):
return Point(self.x * a, self.y * a)
def __rmul__(self, a):
return self * a
def __truediv__(self, a):
return Point(self.x / a, self.y / a)
def norm(self):
return self.x * self.x + self.y * self.y
def abs(self):
return math.sqrt(self.norm())
def __lt__(self, p):
if self.x != p.x:
return self.x < p.x
else:
return self.y < p.y
def __eq__(self, p):
return equals(self.x, p.x) and equals(self.y, p.y)
class Segment:
def __init__(self, p1, p2):
self.p1 = p1
self.p2 = p2
def dot(a, b):
return a.x * b.x + a.y * b.y
def cross(a, b):
return a.x * b.y - a.y * b.x
def ccw(p0, p1, p2):
COUNTER_CLOCKWISE = 1
CLOCKWISE = -1
ONLINE_BACK = 2
ONLINE_FRONT = -2
ON_SEGMENT = 0
a = p1 - p0
b = p2 - p0
if cross(a, b) > EPS:
return COUNTER_CLOCKWISE
if cross(a, b) < -EPS:
return CLOCKWISE
if dot(a, b) < -EPS:
return ONLINE_BACK
if a.norm() < b.norm():
return ONLINE_FRONT
return ON_SEGMENT
def intersect(s1, s2):
p1 = s1.p1
p2 = s1.p2
p3 = s2.p1
p4 = s2.p2
return (
ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0
and ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0
)
if __name__ == "__main__":
q = int(input())
ans = []
for i in range(q):
x0, y0, x1, y1, x2, y2, x3, y3 = [int(v) for v in input().split()]
s1 = Segment(Point(x0, y0), Point(x1, y1))
s2 = Segment(Point(x2, y2), Point(x3, y3))
ans.append(intersect(s1, s2))
for v in ans:
print(int(v))
|
Intersection
For given two segments s1 and s2, print "1" if they are intersect, "0"
otherwise.
s1 is formed by end points p0 and p1, and s2 is formed by end points p2 and
p3.
|
[{"input": "3\n 0 0 3 0 1 1 2 -1\n 0 0 3 0 3 1 3 -1\n 0 0 3 0 3 -2 5 0", "output": "1\n 1\n 0"}]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.