output_description stringlengths 15 956 | submission_id stringlengths 10 10 | status stringclasses 3 values | problem_id stringlengths 6 6 | input_description stringlengths 9 2.55k | attempt stringlengths 1 13.7k | problem_description stringlengths 7 5.24k | samples stringlengths 2 2.72k |
|---|---|---|---|---|---|---|---|
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s741336542 | Runtime Error | p03605 | Input is given from Standard Input in the following format:
N | import random
a=input()
kekka=['Yes','No']
print(random.choice(kekka) | Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s883780319 | Runtime Error | p03605 | Input is given from Standard Input in the following format:
N | if input().find("9")>-1:
print("Yes")
else:
print("No")
| Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s068904126 | Runtime Error | p03605 | Input is given from Standard Input in the following format:
N | a = int(input())
if (a/10 == 9 || a%10 == 9):
print("yes")
else:
print("No") | Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s023954630 | Runtime Error | p03605 | Input is given from Standard Input in the following format:
N | # 今日、日本は9月9日である。
# 2桁の整数Nが与えられる。
# Nに9が含まれるか調べ、含まれていればYes、そうでなければNoを出力する
def September9(num):
if (num // 10) == 9:
print("Yes")
elif (num % 10) == 9:
print("Yes")
else:
print("No")
if __name__ == "__main__":
N = int( input())
September9(N) # September9()の実行
~ | Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s670489413 | Runtime Error | p03605 | Input is given from Standard Input in the following format:
N | a = int(input())
b = a // 10
c = a % 10
if b == 9 or c == 9
print("yes")
else
print("no") | Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s362382066 | Runtime Error | p03605 | Input is given from Standard Input in the following format:
N | from itertools import permutations
inf = 10**9
n, m, r1 = map(int, input().split())
r = list(map(int, input().split()))
abc = [list(map(int, input().split())) for _ in range(m)]
d = [[inf] * n for i in range(n)]
for ai, bi, ci in abc:
d[ai - 1][bi - 1] = ci
d[bi - 1][ai - 1] = ci
for k in range(n):
for i in range(n - 1):
for j in range(i, n):
dk = d[i][k] + d[k][j]
if d[i][j] > dk:
d[j][i] = dk
d[i][j] = dk
permutations(r)
ans = inf
p = list(permutations(r))
for pi in p:
res = 0
for i in range(r1 - 1):
res += d[pi[i] - 1][pi[i + 1] - 1]
if ans > res:
ans = res
print(ans)
| Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s772891022 | Runtime Error | p03605 | Input is given from Standard Input in the following format:
N | N = int(input())
if N >= 90 or (N+1)%10 is 0:
print("Yes")
else:
print("No") | Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s483529298 | Runtime Error | p03605 | Input is given from Standard Input in the following format:
N | """
N×N のマス目があります。
このマス目の各マスを白色または黒色に塗ることにしました (すべてのマスをどちらか片方の色に塗ります)。
ちょうど A マスを白色に塗るとき、黒色に塗ることになるマスはいくつあるでしょうか。
"""
"""
標準入力は以下の形式で与えられる
-------------------------------
N
A
"""
"""
N,Aの条件
------------------
1 <= N & N <= 100
0 <= A & A <= N**2
"""
"""
出力
-----------------
黒色に塗るマスの個数を出力する
"""
if __name__ == "__main__":
# Nの入力チェック---------------------------------------------------
while True:
try:
N = int(input("整数Nを入力してください。:"))
if (1 <= N) & (N <= 100):
break
else:
print("入力が規定の範囲内に収まっていません。")
print("--------------------------------------")
except ValueError:
print("Nの入力エラーです")
print("--------------------------------------")
# Aの入力チェック----------------------------------------------------
while True:
try:
A = int(input("整数Aを入力してください。:"))
if (1 <= A) & (A <= N * N):
break
else:
print("入力が規定の範囲内に収まっていません。")
print("--------------------------------------")
except ValueError:
print("Aの入力エラーです")
print("--------------------------------------")
# 関数の実行--------------------------------------------------
print(" ###### Result ######")
print(N**2 - A)
| Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s752931079 | Accepted | p03605 | Input is given from Standard Input in the following format:
N | print("Yes" if "9" in list(input()) else "No")
| Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s032076530 | Accepted | p03605 | Input is given from Standard Input in the following format:
N | print(["No", "Yes"][input().count("9") > 0])
| Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s351087983 | Accepted | p03605 | Input is given from Standard Input in the following format:
N | print("YNeos"[not "9" in (input()) :: 2])
| Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s919795990 | Accepted | p03605 | Input is given from Standard Input in the following format:
N | print("Yes" if str(input()).count("9") > 0 else "No")
| Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s320317199 | Accepted | p03605 | Input is given from Standard Input in the following format:
N | print(["Yes", "No"][input().count("9") == 0])
| Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s568753026 | Accepted | p03605 | Input is given from Standard Input in the following format:
N | print("YNeos"[not "9" in list(input()) :: 2])
| Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s800781539 | Wrong Answer | p03605 | Input is given from Standard Input in the following format:
N | N = list(map(int, input()))
print(9 in N)
| Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s330093868 | Wrong Answer | p03605 | Input is given from Standard Input in the following format:
N | print(["Yes", "No"]["9" in input()])
| Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s444505647 | Runtime Error | p03605 | Input is given from Standard Input in the following format:
N | if input().in('9'):
print("Yes")
else:
print("No") | Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
If 9 is contained in the decimal notation of N, print `Yes`; if not, print
`No`.
* * * | s462762062 | Wrong Answer | p03605 | Input is given from Standard Input in the following format:
N | print("Yes" if sorted(list(input()))[1] == 9 else "No")
| Statement
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in
the decimal notation of N? | [{"input": "29", "output": "Yes\n \n\nThe one's digit of 29 is 9.\n\n* * *"}, {"input": "72", "output": "No\n \n\n72 does not contain 9.\n\n* * *"}, {"input": "91", "output": "Yes"}] |
Print the answer.
* * * | s209751991 | Wrong Answer | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | N, X = map(int, input().split()) # ゴミの数、ゴミ箱回収エネルギー
x = list(map(int, input().split()))
energy = 0 # 必要なエネルギーの最小値
nokori = N # 残りのゴミの数
k = 0 # 今持っているゴミの数
x.reverse()
x.append(0)
for i in range(N + 1):
# ゴミを取り行くまでの距離を計算
if i == 0:
d = x[i]
else:
d = x[i - 1] - x[i]
# ゴミを取りに行くエネルギーを計算
if not __debug__:
print(
"{0}のエネルギーを消費して、位置{1}に移動する".format(
(k + 1) ** 2 * d, x[i]
)
)
energy += (k + 1) ** 2 * d
# ゴミを取る(or ゴミをゴミ箱に入れる)エネルギーを計算
if i != N:
k += 1
if not __debug__:
print("{0}のエネルギーを消費して、ゴミを取る".format(X))
else:
if not __debug__:
print("{0}のエネルギーを消費して、{1}つのゴミをゴミ箱に入れる".format(X, k))
energy += X
print(energy)
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s994284190 | Runtime Error | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | N,X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
x.insert(0,0)
x.reverse()
table = [[0 for i in range(N+5)]for j in [0,1] ]
table[0][0] = 0
a = False
for i in range(N):
for j in range(i):
table[not(a)][j+1] = table[a][j] + (j+2)*(j+2)*(x[j] - x[j+1]) + X
table[not(a)][0] = table[a][i-1] + (i+1)*(i+1)*x[i-1] + x[i] + X
a = not(a)
print(table[a])
ans = 10000000000000000
for i in range(N):
ans = min(ans, table[a][i] + (i+2)*(i+2) * x[N-1] + X)
//print(table[a][i] + (i+2)*(i+2) * x[N-1] + X,i)
print(ans)
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s611323466 | Runtime Error | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | import sys
N,X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
x.insert(0,0)
x.reverse()
table = [[0 for i in range(N+5)]for j in [0,1] ]
table[0][0] = 0
a = False
for i in range(N):
for j in range(i):
table[not(a)][j+1] = table[a][j] + (j+2)*(j+2)*(x[j] - x[j+1]) + X
table[not(a)][0] = table[a][i-1] + (i+1)*(i+1)*x[i-1] + x[i] + X
a = not(a)
print(table[a])
ans = sys.maxsize
for i in range(N):
ans = min(ans, table[a][i] + (i+2)*(i+2) * x[N-1] + X)
//print(table[a][i] + (i+2)*(i+2) * x[N-1] + X,i)
print(ans)
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s459266830 | Runtime Error | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | import math
N,X=map(int,input().split())
nums = list(map(int,input().split()))
tmp = (N-1)
if tmp == 0:
print(2*X+pow(nums[0],2)+4*nums[0])
exit()
total = nums[tmp] + X
count = 1
now = nums[tmp]
tmp -= 1
while 0 <= tmp:
if 1 < tmp and 2*nums[tmp-1]*(count-1) => X:
total += (X + pow((count+1),2)*now)
now = nums[tmp]
count = 1
tmp -= 1
total += (now + X)
else:
total += (now - nums[tmp])*pow((count+1),2) + X
now = nums[tmp]
count += 1
tmp -= 1
total += (nums[0]*pow((count+1),2)) + X
print(total)
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s215359939 | Runtime Error | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | #include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;
typedef unsigned long long uLL;
int main(){
int n;cin >> n;
uLL x;cin >> x;
vector<uLL> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<uLL> cum(n+1,0);
sort(ALL(a),greater<uLL>());
for (int i = 0; i < n; i++) {
cum[i+1]+=cum[i]+a[i];
}
uLL ans = ULONG_MAX;
for (int k = 1; k <= n; k++) {
uLL tmp = (n+k)*x;
for (uLL i = 0; i*k <= n; i++) {
if((i+1)*k>n){
if(i==0) tmp += (cum[n] - cum[i*k])*5;
else tmp += (cum[n] - cum[i*k])*(2*(i+1)+1);
break;
}
else{
if(i==0) tmp += (cum[(i+1)*k] - cum[i*k])*5;
else tmp += (cum[(i+1)*k] - cum[i*k])*(2*(i+1)+1);
}
}
ans = min(ans,tmp);
}
cout << ans << endl;
return 0;
}
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s319036696 | Wrong Answer | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | N, X = tuple(int(i) for i in input().split())
x = sorted([int(i) for i in input().split()], reverse=True)
def f(x):
xb = 0
s = 0
for i, x_ in enumerate(x):
s += abs(x_ - xb) * ((i + 1) ** 2) + X
xb = x_
return s
x.append(0)
x_d = [f(x[i:]) for i in range(N)]
ss = 0
s = x[0] + X
k = 2
for xa, xb, ra, rb in zip(x[:-1], x[1:], x_d[:-1], x_d[1:]):
k2 = k**2
gb = xa * k2 + X
# print("x:", xa, xb, "r:", ra, rb, "gb:", gb, s, ss)
if ra - s > rb + gb:
ss += s + gb
s = xb + X
k = 2
else:
s += gb - xb * k2
k += 1
g = (k**2) * x[-2] + X
# print(ss, s, g)
print(ss + s + g)
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s724823834 | Wrong Answer | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | n, x = [int(_) for _ in input().split()]
xl = [int(_) for _ in input().split()]
roop = []
firstcost = 5 * xl[n - 1] + 2 * x
firstroop = [1, firstcost]
roop.append(firstroop)
for i in range(n - 2, -1, -1):
for j in range(len(roop)):
pointer = 0
m = float("inf")
if roop[j][0] <= m:
m = roop[j][0]
pointer = j
r_cost = x + 5 * xl[i] + ((m + 1) ** 2) * xl[i]
c_cost = ((m + 1 + 1) ** 2) * xl[i]
if r_cost <= c_cost:
cost = 5 * xl[i] + 2 * x
roop.append([1, cost])
else:
cost = x + ((m + 2) ** 2 - (m + 1) ** 2) * xl[i]
roop[pointer][0] += 1
roop[pointer][1] += cost
total = 0
for i in range(len(roop)):
total += roop[i][1]
print(total)
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s112729555 | Wrong Answer | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [a[0]]
for i in range(n - 1):
b.append(a[i + 1] - a[i])
def root1(num):
go = a[num]
back = a[num] * (1 + 1) ** 2
hirou = x
suteru = x
energy = go + back + hirou + suteru
return energy
energy = root1(0)
go = 0
back = 0
kosuu = 0
startnumber = 0
energy_stock = 0
for i in range(n):
kosuu += 1
go += b[i]
back = 0
kosuuloop = kosuu
for j in range(startnumber, startnumber + kosuu):
back += b[j] * (1 + kosuuloop) ** 2
kosuuloop -= 1
hirou = kosuu * x
suteru = x
new_energy = go + back + hirou + suteru
if energy + root1(i) < new_energy:
energy_stock += energy
energy = root1(i)
b[i] = go
startnumber = i
kosuu = 1
else:
energy = new_energy
print(energy + energy_stock)
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s279912981 | Wrong Answer | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | from bisect import bisect_left
n, x = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
a2, b, b2, ans, num = [0], [], [], n * x, n
for i in a:
a2.append(a2[-1] + i)
for i in range(1, 31):
bi = bisect_left(a, x / (2**i))
b.append(bi)
b2.append(num - bi)
num = bi
if bi == 0:
break
for i in range(n - 1, n - b2[0] - 1, -1):
ans += a[i] * 5
ans += x * (b2[0] // 2)
for i in range(1, len(b)):
ans += (a2[b[i] - 1] - a2[b[i] - min(b2[0] // 2, b2[i]) - 1]) * (2 * i + 5)
b[i] = max(0, b[i] - b2[0] // 2)
while sum(b2):
c = b2[0] % 2
for i in range(1, len(b)):
if b2[i] > 0:
if b2[i] > i + 2 - c:
k = i + 2 - c
for j in range(b[i] + b2[i] - 1, b[i] + b2[i] - 2 - k, -1):
if c > 1:
ans += (2 * c + 3) * a[j]
else:
ans += 5 * a[j]
c += 1
b2[i] -= k
else:
for j in range(b[i] + b2[i] - 1, b[i] - 1, -1):
if c > 1:
ans += (2 * c + 3) * a[j]
else:
ans += 5 * a[j]
c += 1
b2[i] = 0
if b2[0]:
b2[0] = 0
ans += x
print(ans)
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s406307308 | Accepted | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | N, X = map(int, input().split())
x_list = list(map(int, input().split()))
x_cumsum = [0] * N
cum = 0
for i in range(N):
cum += x_list[i]
x_cumsum[i] = cum
res = cum * 5 + 2 * N * X
for n in range(1, N):
res_temp = (N + n) * X
for i in range(N // n):
if i == 0:
c = 5
else:
c = 2 * i + 3
if N - 1 - (i + 1) * n == -1:
res_temp += c * x_cumsum[N - 1 - i * n]
else:
res_temp += c * (x_cumsum[N - 1 - i * n] - x_cumsum[N - 1 - (i + 1) * n])
i = N // n
c = 2 * i + 3
if N % n != 0:
res_temp += c * x_cumsum[N % n - 1]
res = min(res, res_temp)
print(res)
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s487147590 | Wrong Answer | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | N = 212345
dk = [None for i in range(N)]
def g(a, x):
return a[0] * x + a[1]
def ok(a, b, c):
return (c[1] - a[1]) * (a[0] - b[0]) <= (b[1] - a[1]) * (a[0] - c[0])
l, r = 0, 1
x, s, f, dp = [0], [0], [0], [0]
n, c = map(int, input().split())
dk[0] = (0, 0)
for i, xi in enumerate(input().split(), 1):
# if i % 10000 == 0: print(i,len(dp))
x.append(int(xi))
s.append(x[i] + s[i - 1])
f.append(f[i - 1] + 2 * s[i - 1] + x[i])
while r - l > 1 and g(dk[l], i) >= g(dk[l + 1], i):
l += 1
dp.append(g(dk[l], i) + f[i] + 2 * s[i] + 2 * x[i] + c)
now = (-2 * s[i], dp[i] - f[i] + 2 * i * s[i] - 2 * s[i])
while r - l > 1 and ok(dk[r - 2], dk[r - 1], now):
r -= 1
dk[r] = now
r += 1
# BG(i,dp[i],s[i],f[i]);
print(dp[n] + c * n)
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s680220494 | Accepted | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | n, m = map(int, input().split())
x = list(map(int, input().split()))
x.reverse()
cum = [0] * (n + 1)
for i in range(n):
cum[i + 1] = cum[i] + x[i]
mincost = 2 * n * m + 5 * cum[n]
for k in range(1, n):
cost = m * (n + k)
for i in range(n // k):
cost += (cum[(i + 1) * k] - cum[i * k]) * max(5, 3 + i * 2)
cost += (cum[n] - cum[n // k * k]) * max(5, 3 + n // k * 2)
mincost = min(mincost, cost)
print(mincost)
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s176795208 | Wrong Answer | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | import itertools
N, X = map(int, input().split())
x = list(map(int, input().split()))
"""
N = 2
X = 100
x = [1, 10]
"""
p = list(itertools.permutations(x))
minEnergy = 99999999999999999999
for i in range(len(p)):
gomicnt = 0
energy = 0
path = p[i]
for j in range(len(path)):
# 移動量
if j == 0:
l = abs(path[j])
else:
l = abs(path[j] - path[j - 1])
# 移動時に消費するエネルギー
energy = energy + l * (gomicnt + 1) ** 2
# ゴミを取るときに消費するエネルギー
energy = energy + X
gomicnt += 1
# 移動量(最後)
l = abs(path[j] - 0)
# 移動時に消費するエネルギー
energy = energy + l * (gomicnt + 1) ** 2
# ゴミ箱に入れるときに消費するエネルギー
energy = energy + X
minEnergy = min(energy, minEnergy)
print(minEnergy)
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s390273375 | Wrong Answer | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | N, x = map(int, input().split())
A = list(map(int, input().split()))
def run(dist, garb):
return dist * ((garb + 1) ** 2)
def ouhuku(distlist, x):
L = len(distlist)
dista = [0] + distlist
ANS = run(distlist[L - 1], 0)
for i in range(L):
ANS += run(dista[i + 1] - dista[i], L - i)
ANS += x * (L + 1)
return ANS
# N=2のとき,
# 先に一つ次のゴミを取るかは、
# a1=run(A[0],0)+run(A[0],1)+run(A[0],1)+x
# b1=run(A[0],2)
# の差
#
# a1<b1のとき、戻る
# N=kのとき,
# 先に一つ次のゴミを取るかは、
# a2=run(A[1],2)+x+run(A[2],0)+x+run(A[2],1)+x
# b2=run(A[2]-A[1],2)+x+run(A[2],3)+x
# の差
#
# a2<b2のとき、戻る
ANS = 0
now = 0
end = 1
while end < N:
if ouhuku(A[now:end], x) + ouhuku([A[end]], x) < ouhuku(A[now : end + 1], x):
ANS += ouhuku(A[now:end], x)
now = end
end += 1
else:
end += 1
# print(ANS,now,end)
if now < N:
ANS += ouhuku(A[now:end], x)
print(ANS)
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s306360349 | Wrong Answer | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | from itertools import accumulate
import sys
sys.setrecursionlimit(10**8)
N, X = map(int, input().split())
x = [int(i) for i in input().split()]
inf = 10**18
p = [0] + x
p = list(accumulate(p))
m = {}
def f(i, j):
if i == j:
return 2 * X + 5 * x[j]
key = (i, j)
if key in m:
return m[key]
ans = inf
# print(i,j,m)
s = 2 * X + 5 * x[j]
for k in range(i, j):
if k == i:
ans = min(ans, f(k, j - 1) + s)
elif k == i + 1:
s += 5 * x[i] + X
ans = min(ans, f(k, j - 1) + s)
else:
s += 5 * x[k - 1] + X
s += 2 * (p[k - 1] - p[i])
ans = min(ans, f(k, j - 1) + s)
if j == i + 1:
s += X + 5 * x[i]
ans = min(s, ans)
else:
t = j
s += 5 * x[t - 1] + X
s += 2 * (p[t - 1] - p[i])
ans = min(s, ans)
m[key] = ans
return ans
print(f(0, N - 1))
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the answer.
* * * | s424744460 | Wrong Answer | p03255 | Input is given from Standard Input in the following format:
N X
x_1 x_2 ... x_{N} | N, X = tuple(list(map(int, input().split(" "))))
xlis = list(map(int, input().split(" ")))
dp = [pow(10, 18) * i for i in range(N + 1)]
for i in range(1, N + 1):
add = X + 2 * xlis[i - 1]
for j in reversed(list(range(i))):
num = i - j
add += (num + 1) * (num + 1) * xlis[j] - num * num * xlis[j] + X
dp[i] = min([dp[i], dp[j] + add])
print(dp[N])
| Statement
Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is
at position x_i. We would like to put all of them in a trash bin at position
0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq
10^{9} holds.
The robot is initially at position 0. It can freely move left and right along
the number line, pick up a piece of trash when it comes to the position of
that piece, carry any number of pieces of trash and put them in the trash bin
when it comes to position 0. It is not allowed to put pieces of trash anywhere
except in the trash bin.
The robot consumes X points of energy when the robot picks up a piece of
trash, or put pieces of trash in the trash bin. (Putting any number of pieces
of trash in the trash bin consumes X points of energy.) Also, the robot
consumes (k+1)^{2} points of energy to travel by a distance of 1 when the
robot is carrying k pieces of trash.
Find the minimum amount of energy required to put all the N pieces of trash in
the trash bin. | [{"input": "2 100\n 1 10", "output": "355\n \n\n * Travel to position 10 by consuming 10 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 1 by consuming 36 points of energy.\n * Pick up the piece of trash by consuming 100 points of energy.\n * Travel to position 0 by consuming 9 points of energy.\n * Put the two pieces of trash in the trash bin by consuming 100 points of energy.\n\nThis strategy consumes a total of 10+100+36+100+9+100=355 points of energy.\n\n* * *"}, {"input": "5 1\n 1 999999997 999999998 999999999 1000000000", "output": "19999999983\n \n\n* * *"}, {"input": "10 8851025\n 38 87 668 3175 22601 65499 90236 790604 4290609 4894746", "output": "150710136\n \n\n* * *"}, {"input": "16 10\n 1 7 12 27 52 75 731 13856 395504 534840 1276551 2356789 9384806 19108104 82684732 535447408", "output": "3256017715"}] |
Print the area of the polygon in a line. The area should be printed with one
digit to the right of the decimal point. | s675888007 | Accepted | p02297 | The input consists of coordinates of the points p1,..., pn in the following
format:
n
x1 y1
x2 y2
:
xn yn
The first integer n is the number of points. The coordinate of a point pi is
given by two integers xi and yi. The coordinates of points are given in the
order of counter-clockwise visit of them. | n = int(input())
points = [complex(*map(int, input().split())) for _ in range(n)]
result, prev = 0, points[0]
while points:
point = points.pop()
result += point.real * prev.imag - prev.real * point.imag
prev = point
print(abs(result) / 2)
| Area
For a given polygon g, computes the area of the polygon.
g is represented by a sequence of points p1, p2,..., pn where line segments
connecting pi and pi+1 (1 ≤ i ≤ n-1) are sides of g. The line segment
connecting pn and p1 is also a side of the polygon.
Note that the polygon is not necessarily convex. | [{"input": "3\n 0 0\n 2 2\n -1 1", "output": "2.0"}, {"input": "4\n 0 0\n 1 1\n 1 2\n 0 2", "output": "1.5"}] |
Print the area of the polygon in a line. The area should be printed with one
digit to the right of the decimal point. | s256618601 | Accepted | p02297 | The input consists of coordinates of the points p1,..., pn in the following
format:
n
x1 y1
x2 y2
:
xn yn
The first integer n is the number of points. The coordinate of a point pi is
given by two integers xi and yi. The coordinates of points are given in the
order of counter-clockwise visit of them. | p = [complex(*map(int, input().split())) for _ in range(int(input()))]
s, pre = 0, p[0]
while p:
now = p.pop()
s += now.real * pre.imag - now.imag * pre.real
pre = now
print(abs(s) / 2)
| Area
For a given polygon g, computes the area of the polygon.
g is represented by a sequence of points p1, p2,..., pn where line segments
connecting pi and pi+1 (1 ≤ i ≤ n-1) are sides of g. The line segment
connecting pn and p1 is also a side of the polygon.
Note that the polygon is not necessarily convex. | [{"input": "3\n 0 0\n 2 2\n -1 1", "output": "2.0"}, {"input": "4\n 0 0\n 1 1\n 1 2\n 0 2", "output": "1.5"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s514974495 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | s = list(input())
t = list(input())
s.sort()
s=''.join(s)
t.reverse()
t=''.join(t)
if s =< t:
print('Yes')
else:
print('No') | Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s827782025 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | x=sorted(list(input()))
y=sorted(list(input()),reverse=true)
a=""
b=""
for (p,q) in zip x,y:
a+=p
b+=q
if a<b:
print("Yes")
else:
print("No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s279942574 | Accepted | p03486 | Input is given from Standard Input in the following format:
s
t | a, b = [sorted(input()) for i in range(2)]
print("Yes" if a < b[::-1] else "No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s625163455 | Accepted | p03486 | Input is given from Standard Input in the following format:
s
t | i, s = input, sorted
print(["No", "Yes"]["".join(s(i())) < "".join(s(i()))[::-1]])
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s283892903 | Wrong Answer | p03486 | Input is given from Standard Input in the following format:
s
t | print("Yes" if sorted(input()) < sorted(input()) else "No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s115579061 | Wrong Answer | p03486 | Input is given from Standard Input in the following format:
s
t | s = sorted(x for x in input())
t = sorted([x for x in input()], reverse=True)
print("Yes" if s <= t else "No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s025496178 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | impport sys
S = [ord(i) for i in input()]
T = [ord(j) for j in input()]
S.sort()
T.sort()
for k in range(len(S)):
if S[k] > T[k]:
print("No")
sys.exit()
elif S[k] < T[k]:
print("Yes")
sys.exit()
else:
None
if len(S) <= len(T):
print("Yes")
else:
print("No") | Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s407763678 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | s = list(input())
t = list(input())
for i in s:
for j in t:
if ord(i)<ord(j):
print("Yes")
exit()
count = 0
if len(s)<len(t):
for i in range(len(s)):
if s[i]=t[i]:
count+=1
if count = len(s):
print("Yes")
exit()
print("No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s865173643 | Accepted | p03486 | Input is given from Standard Input in the following format:
s
t | #!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():
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__":
B()
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s829213425 | Accepted | p03486 | Input is given from Standard Input in the following format:
s
t | import sys
from sys import exit
from collections import deque
from bisect import (
bisect_left,
bisect_right,
insort_left,
insort_right,
) # func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *
sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9 + 7
def mint():
return map(int, input().split())
def lint():
return list(map(int, input().split()))
def ilint():
return int(input()), list(map(int, input().split()))
def judge(x, l=["Yes", "No"]):
print(l[0] if x else l[1])
def lprint(l, sep="\n"):
for x in l:
print(x, end=sep)
s, t = input(), input()
def str_to_list(x):
l = []
for i in range(len(x)):
l.append(ord(x[i]))
return l
def list_to_str(l):
l = list(map(chr, l))
return "".join(l)
s = str_to_list(s)
s.sort()
s = list_to_str(s)
t = str_to_list(t)
t.sort(reverse=True)
t = list_to_str(t)
judge(s < t)
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s021865996 | Accepted | p03486 | Input is given from Standard Input in the following format:
s
t | print("Yes" if sorted(list(input())) < sorted(list(input()), reverse=1) else "No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s345712734 | Accepted | p03486 | Input is given from Standard Input in the following format:
s
t | a = list(input())
b = list(input())
for i in range(len(a) - 1):
for j in range(len(a) - i - 1):
if a[j] >= a[j + 1]:
a[j], a[j + 1] = a[j + 1], a[j]
for i in range(len(b) - 1):
for j in range(len(b) - i - 1):
if b[j] >= b[j + 1]:
b[j], b[j + 1] = b[j + 1], b[j]
a_string = "".join(a)
b_string = "".join(b[::-1])
if a_string < b_string:
print("Yes")
else:
print("No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s913866283 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | a = list(input())
b = list(input())
a.sort()
b.sort()
print("Yes" if "".join(a) < "".join(b) else "No") | Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s974425112 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | in1.sort() = [c for c in input()]
in2.sort(reversed=1) = [c for c in input()]
print("Yes" if in1 < in2 else "No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s749705704 | Wrong Answer | p03486 | Input is given from Standard Input in the following format:
s
t | print("yes" if sorted(input()) < sorted(input(), reverse=True) else "No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s703136345 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | print("Yes" if [c for c in input()].sort()<[c for c in input()].sort(reversed=1) else "No"
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s086408106 | Wrong Answer | p03486 | Input is given from Standard Input in the following format:
s
t | print("Yes" if max(input()) > min(input()) else "No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s014772336 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | s, t = [input() for _ in range(2)]
jprint("Yes" if sorted(s) < sorted(t, reverse=True) else "No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s723006368 | Wrong Answer | p03486 | Input is given from Standard Input in the following format:
s
t | s, t = open(0)
print("YNeos"["".join(sorted(s[:-1])) >= "".join(sorted(t, reverse=True)) :: 2])
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s656746060 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | A=sorted(list(input()))
B=sorted(list(input()))
if len(A)<=len(B):
for i in range len(A)-1:
if A(i)<=B(i):
print("Yes")
else:
print("No") | Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s799286342 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | %%test_input https://atcoder.jp/contests/abc082/tasks/abc082_b
#B
import collections
s = str(input())
t = str(input())
sd = list(s)
td = list(t)
sd.sort()
td.sort(reverse=True)
a = ''
b = ''
for c in sd:
a += c
for c in td:
b += c
if sd < td:
print('Yes')
else:
print('No') | Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s944006039 | Wrong Answer | p03486 | Input is given from Standard Input in the following format:
s
t | a = input()
b = input()
aa = []
for i in range(len(a)):
aa.append(ord(a[i]))
# print(aa)
aa.sort()
# print(aa)
ansa = ""
for i in range(len(a)):
ansa += chr(aa[i])
# print(ansa)
bb = []
for i in range(len(b)):
bb.append(ord(b[i]))
# print(bb)
bb.sort()
bb.reverse()
# print(bb)
ansb = ""
for i in range(len(b)):
ansb += chr(bb[i])
# print(ansb)
ans = "No"
for i in range(min(len(ansa), len(ansb))):
if ansa[i] < ansb[i]:
ans = "Yes"
break
print(ans)
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s226723082 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | #!/user/bin/python
# coding: UTF-8
s = input()
t = input()
s_list = list(s)
t_list = list(t)
def a2n(alfabet):
for i in range(len(alfabet)):
if alfabet[i] == "a":
alfabet[i] = 1
elif alfabet[i] == "b":
alfabet[i] = 2
elif alfabet[i] == "c":
alfabet[i] = 3
elif alfabet[i] == "d":
alfabet[i] = 4
elif alfabet[i] == "e":
alfabet[i] = 5
elif alfabet[i] == "f":
alfabet[i] = 6
elif alfabet[i] == "g":
alfabet[i] = 7
elif alfabet[i] == "h":
alfabet[i] = 8
elif alfabet[i] == "i":
alfabet[i] = 9
elif alfabet[i] == "j":
alfabet[i] = 10
elif alfabet[i] == "k":
alfabet[i] = 11
elif alfabet[i] == "l":
alfabet[i] = 12
elif alfabet[i] == "m":
alfabet[i] = 13
elif alfabet[i] == "n":
alfabet[i] = 14
elif alfabet[i] == "o":
alfabet[i] = 15
elif alfabet[i] == "p":
alfabet[i] = 16
elif alfabet[i] == "q":
alfabet[i] = 17
elif alfabet[i] == "r":
alfabet[i] = 18
elif alfabet[i] == "s":
alfabet[i] = 19
elif alfabet[i] == "t":
alfabet[i] = 20
elif alfabet[i] == "u":
alfabet[i] = 21
elif alfabet[i] == "v":
alfabet[i] = 22
elif alfabet[i] == "w":
alfabet[i] = 23
elif alfabet[i] == "x":
alfabet[i] = 24
elif alfabet[i] == "y":
alfabet[i] = 25
elif alfabet[i] == "z":
alfabet[i] = 26
return alfabet
ns = a2n(s_list)
ns.sort()
nt = a2n(t_list)
nt.sort()
nt.reverse()
for i in range(len(ns)):
if ns[i] == nt[i]:
ans = "next"
elif ns[i] < nt[i]:
ans = "Yes"
break
elif ns[i] > nt[i]:
ans = "No"
break
if ans == "next":
if len(ns) < len(nt):
ans = "Yes"
else:
ans = "No"
print(ans)
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s593744484 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | s = "".join(sorted(list(input())))
t = "".join(sorte(list(input()),reverse = True))
is s < t:
print("Yes")
else:
print("No") | Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s212919300 | Accepted | p03486 | Input is given from Standard Input in the following format:
s
t | print("Yes" if sorted(input()) < sorted(input(), reverse=1) else "No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s790053364 | Wrong Answer | p03486 | Input is given from Standard Input in the following format:
s
t | print("Yes" if min(input()) < max(input()) else "No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s396975860 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | S = sorted(list(str(input())))
T = sorted(list(str(input())),reverse=True)
print('YNeos'[S>=::2]) | Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s649784028 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | print("Yes" if print(sorted(input())) < print(sorted(input())[::-1]) else "No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s221255108 | Wrong Answer | p03486 | Input is given from Standard Input in the following format:
s
t | print("Yes") if sorted(input()) < sorted(input()) else print("No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s467696034 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | s = sorted(input())
z = sorted(input()), reverse=True
c=len(s) if len(s) <= len(z) else =len(z)
for a in range(c):
if s[a] > z[a]:
print('No')
exit()
if len(s) == len(z):
print('Yes')
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s782970368 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | s_input_sort = sorted(list(str(input())))
t_input_sort = sorted(list(str(input())), reverse=True)
s_str = "".join(s_input_sort)
t_str = "".join(t_input_sort)
if t_str >= s_str:
print("Yes")
else:
print("No") | Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s766952224 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | #
# abc082 b
#
import unittest
from io import StringIO
import sys
def input():
return sys.stdin.readline().rstrip()
def resolve():
s = list(input())
t = list(input())
flag = False
s = sorted(s, reverse=True)
t = sorted(t, reverse=True)
for i in range(min(len(s), len(t)):
if s[i] < t[i]:
flag = True
break
elif s[i] == t[i] and len(s) < len(t):
flag = True
break
if flag == True:
print("Yes")
else:
print("No")
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
out = sys.stdout.read()[:-1]
sys.stdout, sys.stdin = stdout, stdin
self.assertEqual(out, output)
def test_入力例_1(self):
input = """yx
axy"""
output = """Yes"""
self.assertIO(input, output)
def test_入力例_2(self):
input = """ratcode
atlas"""
output = """Yes"""
self.assertIO(input, output)
def test_入力例_3(self):
input = """cd
abc"""
output = """No"""
self.assertIO(input, output)
def test_入力例_4(self):
input = """w
ww"""
output = """Yes"""
self.assertIO(input, output)
def test_入力例_5(self):
input = """zzz
zzz"""
output = """No"""
self.assertIO(input, output)
if __name__ == "__main__":
#unittest.main()
resolve()
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s311738356 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | first = sorted(list(input('')))
second = sorted(list(input('')), reverse=True)
length = len(first) < len(second)
result = False
check_equal = False
for (f, s) in zip(first, second):
check_equal = (s == f)
if !check_equal:
result = (f < s)
break
if (length and check_equal) or result:
print('Yes')
else:
print('No')
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s720464842 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | s = input()
t = input()
s_list = list(s)
t_list = list(t)
s_list.sort()
t_list.sort()
for i in range(min(len(s_list), len(t_list))):
if s_list[i] < t_list[i]:
print('Yes')
break
elif s_list[i] > t_list[i]
print('No')
break
else:
if i == min(len(s_list), len(t_list)):
if len(s_list) < len(t_list):
print('Yes')
else
print('No')
else
continue
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s382067021 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | from itertools import zip_longest
def twoAnagrams(s, t):
s_str = ''.join(sorted(s))
t_str = ''.join(sorted(t, reverse=True))
if t_str.startswith(s_str):
if len(s_str) < len(t_str):
return True
# this implies s and t is the same string
else:
return False
for s_chr,t_chr in zip_longest(s_str, t_str):
if s_chr is None:
return True
elif t_chr is None or t_chr < s_chr:
return False
else s_chr < t_chr:
return True
s = list(input())
t = list(input())
print('Yes' if twoAnagrams(s,t) else 'No')
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s709621054 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | s = input()
t = input()
s1 = [str(a) for a in s]
t1 = [str(a) for a in t]
s1.sort()
t1.sort()
import copy
t2 = copy.copy(t1)
for i in range(len(t1)):
t1[i] = t2[len(t1)-i-1]
if len(s) < len(t):
k = 0
for i in range(len(s)):
if s1[i] == t1[i]:
k = k + 1
if k = len(s):
print('Yes')
else:
print('No')
else:
n = 0
l = 0
i = 0
while n==0 and i < len(t):
if s1[i] == t1[i]:
l = l + 1
i = i + 1
elif s1[i] < t1[i]:
n = n + 1
print('Yes')
elif s1[i] > t1[i]:
n = n + 1
print('No')
if l = len(t):
print('No') | Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s011960513 | Accepted | p03486 | Input is given from Standard Input in the following format:
s
t | print("Yes" if "".join(sorted(input())) < "".join(sorted(input())[::-1]) else "No")
| Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
If it is possible to satisfy s' < t', print `Yes`; if it is not, print `No`.
* * * | s094240982 | Runtime Error | p03486 | Input is given from Standard Input in the following format:
s
t | s = input()
t = input()
exit()
s = list(s)
t = list(t)
s_ = sorted(s)
t_ = sorted(t)
t_.reverse()
if ''.join(s_)<''.join(t_):
print('Yes')
else:
print('No') | Statement
You are given strings s and t, consisting of lowercase English letters. You
will create a string s' by freely rearranging the characters in s. You will
also create a string t' by freely rearranging the characters in t. Determine
whether it is possible to satisfy s' < t' for the lexicographic order. | [{"input": "yx\n axy", "output": "Yes\n \n\nWe can, for example, rearrange `yx` into `xy` and `axy` into `yxa`. Then, `xy`\n< `yxa`.\n\n* * *"}, {"input": "ratcode\n atlas", "output": "Yes\n \n\nWe can, for example, rearrange `ratcode` into `acdeort` and `atlas` into\n`tslaa`. Then, `acdeort` < `tslaa`.\n\n* * *"}, {"input": "cd\n abc", "output": "No\n \n\nNo matter how we rearrange `cd` and `abc`, we cannot achieve our objective.\n\n* * *"}, {"input": "w\n ww", "output": "Yes\n \n\n* * *"}, {"input": "zzz\n zzz", "output": "No"}] |
Print the sum of the costs of all possible arrangements of the pieces, modulo
10^9+7.
* * * | s510045996 | Accepted | p03039 | Input is given from Standard Input in the following format:
N M K | def e_cell_distance(N, M, K, MOD=10**9 + 7):
class Combination(object):
"""
組み合わせ
参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb
"""
__slots__ = ["mod", "factorial", "inverse"]
def __init__(self, max_n: int = 10**6, mod: int = 10**9 + 7):
fac, inv = [1], []
fac_append, inv_append = fac.append, inv.append
for i in range(1, max_n + 1):
fac_append(fac[-1] * i % mod)
inv_append(pow(fac[-1], mod - 2, mod))
for i in range(max_n, 0, -1):
inv_append(inv[-1] * i % mod)
self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]
def combination(self, n, r):
if r == n or r == 0:
return 1
if r > n:
return 0
return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod
comb = Combination(N * M).combination(N * M - 2, K - 2)
t1 = sum([d * (M - d) * (N**2) for d in range(1, M)])
t2 = sum([d * (N - d) * (M**2) for d in range(1, N)])
t = (t1 + t2) % MOD
return (comb * t) % MOD
N, M, K = [int(i) for i in input().split()]
print(e_cell_distance(N, M, K))
| Statement
We have a grid of squares with N rows and M columns. Let (i, j) denote the
square at the i-th row from the top and j-th column from the left. We will
choose K of the squares and put a piece on each of them.
If we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K,
y_K), the _cost_ of this arrangement is computed as:
\sum_{i=1}^{K-1} \sum_{j=i+1}^K (|x_i - x_j| + |y_i - y_j|)
Find the sum of the costs of all possible arrangements of the pieces. Since
this value can be tremendous, print it modulo 10^9+7.
We consider two arrangements of the pieces different if and only if there is a
square that contains a piece in one of the arrangements but not in the other. | [{"input": "2 2 2", "output": "8\n \n\nThere are six possible arrangements of the pieces, as follows:\n\n * ((1,1),(1,2)), with the cost |1-1|+|1-2| = 1\n * ((1,1),(2,1)), with the cost |1-2|+|1-1| = 1\n * ((1,1),(2,2)), with the cost |1-2|+|1-2| = 2\n * ((1,2),(2,1)), with the cost |1-2|+|2-1| = 2\n * ((1,2),(2,2)), with the cost |1-2|+|2-2| = 1\n * ((2,1),(2,2)), with the cost |2-2|+|1-2| = 1\n\nThe sum of these costs is 8.\n\n* * *"}, {"input": "4 5 4", "output": "87210\n \n\n* * *"}, {"input": "100 100 5000", "output": "817260251\n \n\nBe sure to print the sum modulo 10^9+7."}] |
Print the sum of the costs of all possible arrangements of the pieces, modulo
10^9+7.
* * * | s541026106 | Accepted | p03039 | Input is given from Standard Input in the following format:
N M K | p, q, r = map(int, input().split())
def comb_mod(N, K, modp):
K_fact = 1
NK_fact = 1
N_fact = 1
for i in range(1, K + 1):
K_fact *= i
K_fact = K_fact % modp
for i in range(1, N - K + 1):
NK_fact *= i
NK_fact = NK_fact % modp
for i in range(1, N + 1):
N_fact *= i
N_fact = N_fact % modp
K_inv = pow(K_fact, -1, modp)
NK_inv = pow(NK_fact, -1, modp)
pat = (N_fact * K_inv) % modp * NK_inv % modp
return pat
pat = comb_mod(p * q - 2, r - 2, 10**9 + 7)
ans = 0
for i in range(0, q + 1):
ans += i * (q - i) * p * p
ans = ans % (10**9 + 7)
for k in range(0, p + 1):
ans += k * (p - k) * q * q % (10**9 + 7)
ans = ans % (10**9 + 7)
print(ans * pat % (10**9 + 7))
| Statement
We have a grid of squares with N rows and M columns. Let (i, j) denote the
square at the i-th row from the top and j-th column from the left. We will
choose K of the squares and put a piece on each of them.
If we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K,
y_K), the _cost_ of this arrangement is computed as:
\sum_{i=1}^{K-1} \sum_{j=i+1}^K (|x_i - x_j| + |y_i - y_j|)
Find the sum of the costs of all possible arrangements of the pieces. Since
this value can be tremendous, print it modulo 10^9+7.
We consider two arrangements of the pieces different if and only if there is a
square that contains a piece in one of the arrangements but not in the other. | [{"input": "2 2 2", "output": "8\n \n\nThere are six possible arrangements of the pieces, as follows:\n\n * ((1,1),(1,2)), with the cost |1-1|+|1-2| = 1\n * ((1,1),(2,1)), with the cost |1-2|+|1-1| = 1\n * ((1,1),(2,2)), with the cost |1-2|+|1-2| = 2\n * ((1,2),(2,1)), with the cost |1-2|+|2-1| = 2\n * ((1,2),(2,2)), with the cost |1-2|+|2-2| = 1\n * ((2,1),(2,2)), with the cost |2-2|+|1-2| = 1\n\nThe sum of these costs is 8.\n\n* * *"}, {"input": "4 5 4", "output": "87210\n \n\n* * *"}, {"input": "100 100 5000", "output": "817260251\n \n\nBe sure to print the sum modulo 10^9+7."}] |
Print the sum of the costs of all possible arrangements of the pieces, modulo
10^9+7.
* * * | s854957572 | Wrong Answer | p03039 | Input is given from Standard Input in the following format:
N M K | n, m, k = map(int, input().split())
sn = 0
sm = 0
for i in range(n + 1):
sn += (i * (i + 1) + (n - i) * (n - i + 1)) // 2
for i in range(m + 1):
sm += (i * (i + 1) + (m - i) * (m - i + 1)) // 2
sn = sn * ((m + 1) ** 2)
sm = sm * ((n + 1) ** 2)
c = k * (k - 1) / 2
sn = (sn * c) % (10**9 + 7)
sm = (sm * c) % (10**9 + 7)
print((sn + sm) % (10**9 + 7))
| Statement
We have a grid of squares with N rows and M columns. Let (i, j) denote the
square at the i-th row from the top and j-th column from the left. We will
choose K of the squares and put a piece on each of them.
If we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K,
y_K), the _cost_ of this arrangement is computed as:
\sum_{i=1}^{K-1} \sum_{j=i+1}^K (|x_i - x_j| + |y_i - y_j|)
Find the sum of the costs of all possible arrangements of the pieces. Since
this value can be tremendous, print it modulo 10^9+7.
We consider two arrangements of the pieces different if and only if there is a
square that contains a piece in one of the arrangements but not in the other. | [{"input": "2 2 2", "output": "8\n \n\nThere are six possible arrangements of the pieces, as follows:\n\n * ((1,1),(1,2)), with the cost |1-1|+|1-2| = 1\n * ((1,1),(2,1)), with the cost |1-2|+|1-1| = 1\n * ((1,1),(2,2)), with the cost |1-2|+|1-2| = 2\n * ((1,2),(2,1)), with the cost |1-2|+|2-1| = 2\n * ((1,2),(2,2)), with the cost |1-2|+|2-2| = 1\n * ((2,1),(2,2)), with the cost |2-2|+|1-2| = 1\n\nThe sum of these costs is 8.\n\n* * *"}, {"input": "4 5 4", "output": "87210\n \n\n* * *"}, {"input": "100 100 5000", "output": "817260251\n \n\nBe sure to print the sum modulo 10^9+7."}] |
Print the sum of the costs of all possible arrangements of the pieces, modulo
10^9+7.
* * * | s832074492 | Runtime Error | p03039 | Input is given from Standard Input in the following format:
N M K | import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]
if N == 1:
print(max(A[0], BC[0][1]))
quit()
heapq.heapify(A)
for b, c in BC:
a = A[0]
if a >= c:
continue
else:
curPopped = 0
while curPopped < b:
a = heapq.heappop(A)
if a >= c:
heapq.heappush(A, a)
break
curPopped += 1
for i in range(curPopped):
heapq.heappush(A, c)
print(sum(A))
| Statement
We have a grid of squares with N rows and M columns. Let (i, j) denote the
square at the i-th row from the top and j-th column from the left. We will
choose K of the squares and put a piece on each of them.
If we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K,
y_K), the _cost_ of this arrangement is computed as:
\sum_{i=1}^{K-1} \sum_{j=i+1}^K (|x_i - x_j| + |y_i - y_j|)
Find the sum of the costs of all possible arrangements of the pieces. Since
this value can be tremendous, print it modulo 10^9+7.
We consider two arrangements of the pieces different if and only if there is a
square that contains a piece in one of the arrangements but not in the other. | [{"input": "2 2 2", "output": "8\n \n\nThere are six possible arrangements of the pieces, as follows:\n\n * ((1,1),(1,2)), with the cost |1-1|+|1-2| = 1\n * ((1,1),(2,1)), with the cost |1-2|+|1-1| = 1\n * ((1,1),(2,2)), with the cost |1-2|+|1-2| = 2\n * ((1,2),(2,1)), with the cost |1-2|+|2-1| = 2\n * ((1,2),(2,2)), with the cost |1-2|+|2-2| = 1\n * ((2,1),(2,2)), with the cost |2-2|+|1-2| = 1\n\nThe sum of these costs is 8.\n\n* * *"}, {"input": "4 5 4", "output": "87210\n \n\n* * *"}, {"input": "100 100 5000", "output": "817260251\n \n\nBe sure to print the sum modulo 10^9+7."}] |
Print the sum of the costs of all possible arrangements of the pieces, modulo
10^9+7.
* * * | s913370065 | Accepted | p03039 | Input is given from Standard Input in the following format:
N M K | import sys
mod = 7 + 10**9
def comb(n, r, fact, revfact):
return (fact[n] * revfact[n - r] * revfact[r]) % mod
def solve():
input = sys.stdin.readline
N, M, K = map(int, input().split())
fact = [1] * (N * M + 1)
for i in range(1, N * M + 1):
fact[i] = (fact[i - 1] * i) % mod
revfact = [1] * (N * M + 1)
revfact[N * M] = pow(fact[N * M], mod - 2, mod)
for i in reversed(range(1, N * M)):
revfact[i] = ((i + 1) * revfact[i + 1]) % mod
others = comb(N * M - 2, K - 2, fact, revfact)
pair_type = 0
for i in range(N): # 縦の距離がi
if i == 0:
for j in range(1, M): # 横の距離がj
pair_type += (i + j) * (N - i) * (M - j) % mod
pair_type %= mod
else:
for j in range(M):
if j == 0:
pair_type += (i + j) * (N - i) * (M - j) % mod
else:
pair_type += 2 * (i + j) * (N - i) * (M - j) % mod
pair_type %= mod
print(pair_type * others % mod)
return 0
if __name__ == "__main__":
solve()
| Statement
We have a grid of squares with N rows and M columns. Let (i, j) denote the
square at the i-th row from the top and j-th column from the left. We will
choose K of the squares and put a piece on each of them.
If we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K,
y_K), the _cost_ of this arrangement is computed as:
\sum_{i=1}^{K-1} \sum_{j=i+1}^K (|x_i - x_j| + |y_i - y_j|)
Find the sum of the costs of all possible arrangements of the pieces. Since
this value can be tremendous, print it modulo 10^9+7.
We consider two arrangements of the pieces different if and only if there is a
square that contains a piece in one of the arrangements but not in the other. | [{"input": "2 2 2", "output": "8\n \n\nThere are six possible arrangements of the pieces, as follows:\n\n * ((1,1),(1,2)), with the cost |1-1|+|1-2| = 1\n * ((1,1),(2,1)), with the cost |1-2|+|1-1| = 1\n * ((1,1),(2,2)), with the cost |1-2|+|1-2| = 2\n * ((1,2),(2,1)), with the cost |1-2|+|2-1| = 2\n * ((1,2),(2,2)), with the cost |1-2|+|2-2| = 1\n * ((2,1),(2,2)), with the cost |2-2|+|1-2| = 1\n\nThe sum of these costs is 8.\n\n* * *"}, {"input": "4 5 4", "output": "87210\n \n\n* * *"}, {"input": "100 100 5000", "output": "817260251\n \n\nBe sure to print the sum modulo 10^9+7."}] |
Print the sum of the costs of all possible arrangements of the pieces, modulo
10^9+7.
* * * | s687019777 | Accepted | p03039 | Input is given from Standard Input in the following format:
N M K | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
# 2点間の距離の平均を求めればよい
MOD = 10**9 + 7
N, M, K = map(int, read().split())
def cumprod(arr, MOD):
L = len(arr)
Lsq = int(L**0.5 + 1)
arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
for n in range(1, Lsq):
arr[:, n] *= arr[:, n - 1]
arr[:, n] %= MOD
for n in range(1, Lsq):
arr[n] *= arr[n - 1, -1]
arr[n] %= MOD
return arr.ravel()[:L]
def make_fact(U, MOD):
x = np.arange(U, dtype=np.int64)
x[0] = 1
fact = cumprod(x, MOD)
x = np.arange(U, 0, -1, dtype=np.int64)
x[0] = pow(int(fact[-1]), MOD - 2, MOD)
fact_inv = cumprod(x, MOD)[::-1]
return fact, fact_inv
U = 10**6
fact, fact_inv = make_fact(U, MOD)
coef = fact[N * M - 2] * fact_inv[K - 2] % MOD * fact_inv[N * M - K] % MOD
x = (N - 1) * N * (N + 1) * M * M // 6
y = (M - 1) * M * (M + 1) * N * N // 6
answer = coef * ((x + y) % MOD) % MOD
print(answer)
| Statement
We have a grid of squares with N rows and M columns. Let (i, j) denote the
square at the i-th row from the top and j-th column from the left. We will
choose K of the squares and put a piece on each of them.
If we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K,
y_K), the _cost_ of this arrangement is computed as:
\sum_{i=1}^{K-1} \sum_{j=i+1}^K (|x_i - x_j| + |y_i - y_j|)
Find the sum of the costs of all possible arrangements of the pieces. Since
this value can be tremendous, print it modulo 10^9+7.
We consider two arrangements of the pieces different if and only if there is a
square that contains a piece in one of the arrangements but not in the other. | [{"input": "2 2 2", "output": "8\n \n\nThere are six possible arrangements of the pieces, as follows:\n\n * ((1,1),(1,2)), with the cost |1-1|+|1-2| = 1\n * ((1,1),(2,1)), with the cost |1-2|+|1-1| = 1\n * ((1,1),(2,2)), with the cost |1-2|+|1-2| = 2\n * ((1,2),(2,1)), with the cost |1-2|+|2-1| = 2\n * ((1,2),(2,2)), with the cost |1-2|+|2-2| = 1\n * ((2,1),(2,2)), with the cost |2-2|+|1-2| = 1\n\nThe sum of these costs is 8.\n\n* * *"}, {"input": "4 5 4", "output": "87210\n \n\n* * *"}, {"input": "100 100 5000", "output": "817260251\n \n\nBe sure to print the sum modulo 10^9+7."}] |
Print the sum of the costs of all possible arrangements of the pieces, modulo
10^9+7.
* * * | s587196448 | Wrong Answer | p03039 | Input is given from Standard Input in the following format:
N M K | N, M, K = list(map(int, input().split()))
MOD = int(1e9 + 7)
NM = N * M
def su(n):
return n * (n + 1) // 2
class comb:
F = [1, 1]
Fi = [1, 1]
I = [0, 1]
def __init__(self, num, mod):
self.MOD = mod
for i in range(2, num + 1):
self.F.append((self.F[-1] * i) % mod)
self.I.append(mod - self.I[mod % i] * (mod // i) % mod)
self.Fi.append(self.Fi[-1] * self.I[i] % mod)
def com(self, n, k):
if n < k:
return 0
if n < 0 or k < 0:
return 0
return self.F[n] * (self.Fi[k] * self.Fi[n - k] % self.MOD) % self.MOD
co = comb(NM, MOD)
times = co.com(NM - 2, K - 2)
Ans = 0
for i in range(N):
for j in range(M):
k = (su(i) + su(N - i - 1)) * M % MOD
k = k + (su(j) + su(M - j - 1)) * N % MOD
k = k * times // 2 % MOD
Ans += k % MOD
Ans = Ans % MOD
print(Ans)
| Statement
We have a grid of squares with N rows and M columns. Let (i, j) denote the
square at the i-th row from the top and j-th column from the left. We will
choose K of the squares and put a piece on each of them.
If we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K,
y_K), the _cost_ of this arrangement is computed as:
\sum_{i=1}^{K-1} \sum_{j=i+1}^K (|x_i - x_j| + |y_i - y_j|)
Find the sum of the costs of all possible arrangements of the pieces. Since
this value can be tremendous, print it modulo 10^9+7.
We consider two arrangements of the pieces different if and only if there is a
square that contains a piece in one of the arrangements but not in the other. | [{"input": "2 2 2", "output": "8\n \n\nThere are six possible arrangements of the pieces, as follows:\n\n * ((1,1),(1,2)), with the cost |1-1|+|1-2| = 1\n * ((1,1),(2,1)), with the cost |1-2|+|1-1| = 1\n * ((1,1),(2,2)), with the cost |1-2|+|1-2| = 2\n * ((1,2),(2,1)), with the cost |1-2|+|2-1| = 2\n * ((1,2),(2,2)), with the cost |1-2|+|2-2| = 1\n * ((2,1),(2,2)), with the cost |2-2|+|1-2| = 1\n\nThe sum of these costs is 8.\n\n* * *"}, {"input": "4 5 4", "output": "87210\n \n\n* * *"}, {"input": "100 100 5000", "output": "817260251\n \n\nBe sure to print the sum modulo 10^9+7."}] |
Print the answer.
* * * | s334383409 | Runtime Error | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | n, h, w = [int(i) for i in input().split()]
print(sum([lambda a, b: 1 if h <= a and w <= b else 0, [int(i) for i in input().split()] for _ in range(n)])) | Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s057675668 | Runtime Error | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | N,H,W=map(int,input().split())
ans=0
for i in range(N):
a,b=map(int,input().split())
if a>=H and b=W:
ans+=1
print(ans)
| Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s881642373 | Runtime Error | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | count=0
n,h,w=map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
for i in range(n)
if x[i][0]>=h and x[i][1]>=w:
count+=1
print(count) | Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s563491658 | Runtime Error | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | count=0
n,h,w=map(int, input().split())
x = [list(map(int, input().split())) for i in range(n-1)]
for i in range(n-1)
if x[i][0]>=h and x[i][1]>=w:
count=count+1
print(count) | Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s243249795 | Accepted | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | # -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
# from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache
#############
# Constants #
#############
MOD = 10**9 + 7
INF = float("inf")
#############
# Functions #
#############
######INPUT######
def I():
return int(input().strip())
def S():
return input().strip()
def IL():
return list(map(int, input().split()))
def SL():
return list(map(str, input().split()))
def ILs(n):
return list(int(input()) for _ in range(n))
def SLs(n):
return list(input().strip() for _ in range(n))
def ILL(n):
return [list(map(int, input().split())) for _ in range(n)]
def SLL(n):
return [list(map(str, input().split())) for _ in range(n)]
######OUTPUT######
def P(arg):
print(arg)
return
def Y():
print("Yes")
return
def N():
print("No")
return
def E():
exit()
def PE(arg):
print(arg)
exit()
def YE():
print("Yes")
exit()
def NE():
print("No")
exit()
#####Shorten#####
def DD(arg):
return defaultdict(arg)
#####Inverse#####
def inv(n):
return pow(n, MOD - 2, MOD)
######Combination######
kaijo_memo = []
def kaijo(n):
if len(kaijo_memo) > n:
return kaijo_memo[n]
if len(kaijo_memo) == 0:
kaijo_memo.append(1)
while len(kaijo_memo) <= n:
kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
return kaijo_memo[n]
gyaku_kaijo_memo = []
def gyaku_kaijo(n):
if len(gyaku_kaijo_memo) > n:
return gyaku_kaijo_memo[n]
if len(gyaku_kaijo_memo) == 0:
gyaku_kaijo_memo.append(1)
while len(gyaku_kaijo_memo) <= n:
gyaku_kaijo_memo.append(
gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD
)
return gyaku_kaijo_memo[n]
def nCr(n, r):
if n == r:
return 1
if n < r or r < 0:
return 0
ret = 1
ret = ret * kaijo(n) % MOD
ret = ret * gyaku_kaijo(r) % MOD
ret = ret * gyaku_kaijo(n - r) % MOD
return ret
######Factorization######
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-(n**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
arr.append([i, cnt])
if temp != 1:
arr.append([temp, 1])
if arr == []:
arr.append([n, 1])
return arr
#####MakeDivisors######
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
return divisors
#####MakePrimes######
def make_primes(N):
max = int(math.sqrt(N))
seachList = [i for i in range(2, N + 1)]
primeNum = []
while seachList[0] <= max:
primeNum.append(seachList[0])
tmp = seachList[0]
seachList = [i for i in seachList if i % tmp != 0]
primeNum.extend(seachList)
return primeNum
#####GCD#####
def gcd(a, b):
while b:
a, b = b, a % b
return a
#####LCM#####
def lcm(a, b):
return a * b // gcd(a, b)
#####BitCount#####
def count_bit(n):
count = 0
while n:
n &= n - 1
count += 1
return count
#####ChangeBase#####
def base_10_to_n(X, n):
if X // n:
return base_10_to_n(X // n, n) + [X % n]
return [X % n]
def base_n_to_10(X, n):
return sum(int(str(X)[-i - 1]) * n**i for i in range(len(str(X))))
#####IntLog#####
def int_log(n, a):
count = 0
while n >= a:
n //= a
count += 1
return count
#############
# Main Code #
#############
N, H, W = IL()
ans = 0
for _ in range(N):
a, b = IL()
if a >= H and b >= W:
ans += 1
print(ans)
| Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s693842761 | Accepted | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left, bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil, pi, factorial
from operator import itemgetter
def I():
return int(input())
def MI():
return map(int, input().split())
def LI():
return list(map(int, input().split()))
def LI2():
return [int(input()) for i in range(n)]
def MXI():
return [[LI()] for i in range(n)]
def SI():
return input().rstrip()
def printns(x):
print("\n".join(x))
def printni(x):
print("\n".join(list(map(str, x))))
inf = 10**17
mod = 10**9 + 7
# main code here!
n, h, w = MI()
count = 0
for i in range(n):
x, y = MI()
if h <= x and w <= y:
count += 1
print(count)
if __name__ == "__main__":
main()
| Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s600944336 | Runtime Error | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | count=0
n,h,w=map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
for i in x
if x[i][0]>=h and x[i][1]>=w:
count=count+1
print(count) | Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s039833081 | Accepted | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | nhw = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(nhw[0])]
ab.sort(reverse=True)
aba = [i for i in ab if i[0] >= nhw[1]]
abab = [i for i in aba if i[1] >= nhw[2]]
print(len(abab))
| Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s670819776 | Accepted | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | # _*_ coding:utf-8 _*_
# CADDi2018 for Beginners B AtCoderAlloy
# https://atcoder.jp/contests/caddi2018b/tasks/caddi2018b_b
def checkGetArroy(getArroyHeight, getArroyWidth, nowArroyHeight, nowArroyWidth):
if (getArroyHeight <= nowArroyHeight) and (getArroyWidth <= nowArroyWidth):
return True
else:
return False
def countGetArroy(
allArroyNumber, arroyHeight, arroyWidth, eachArroyHeightList, eachArroyWidthList
):
counter = 0
patternRange = range(0, allArroyNumber, 1)
for i in patternRange:
checkResult = checkGetArroy(
arroyHeight, arroyWidth, eachArroyHeightList[i], eachArroyWidthList[i]
)
if checkResult == True:
counter = counter + 1
return counter
if __name__ == "__main__":
n, h, w = map(int, input().strip().split(" "))
alloyRange = range(0, n, 1)
heightList = []
widthList = []
for i in alloyRange:
tmpHeight, tmpWidth = map(int, input().strip().split(" "))
heightList.append(tmpHeight)
widthList.append(tmpWidth)
solution = countGetArroy(n, h, w, heightList, widthList)
print(solution)
| Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s456838348 | Runtime Error | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | n, h, w = map(int, input().split())
ans = 0
for i in range(n):
a, b = map(int, input().split())
if a >= h and b >= w:
ans += 1
print(ans | Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s636113718 | Runtime Error | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | n, h, w = map(int, input().split())
a_b = [list(map(int, input().split())) for _ range(n)]
cnt = 0
for i in range(n):
if a_b[i][0] >= h and a_b[i][1] >= w:
cnt += 1
print(cnt) | Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s083317139 | Runtime Error | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | 10 587586158 185430194
894597290 708587790
680395892 306946994
590262034 785368612
922328576 106880540
847058850 326169610
936315062 193149191
702035777 223363392
11672949 146832978
779291680 334178158
615808191 701464268 | Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s569700606 | Runtime Error | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | #include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
int n,h,w;cin>>n>>h>>w;
int ans=0;
rep(i,n){
int a,b;cin>>a>>b;
if(a>=h and b>=w)ans++;
}
cout<<ans<<endl;
return 0;
}
| Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s887004378 | Accepted | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | N, H, W = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for _ in range(N)]
print(sum([1 for a, b in AB if a >= H and b >= W]))
| Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s755006124 | Accepted | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | n, h, w, *c = map(int, open(0).read().split())
print(sum((a >= h) & (b >= w) for a, b in zip(c[::2], c[1::2])))
| Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s336114219 | Accepted | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | n, h, w, *t = map(int, open(0).read().split())
print(sum(a >= h and b >= w for a, b in zip(t[::2], t[1::2])))
| Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s794450880 | Runtime Error | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | from numpy import array
n,h,w = [int(x) for x in input().split()]
c = 0
for _ in range(n):
d = array([h,w])array([int(x) for x in input().split()])
c += 1 if False in d else 0
print(c) | Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s269826874 | Runtime Error | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | N = int(input())
H = int(input())
W = int(input())
n = 0
while n < N:
A = int(input())
B = int(input())
n += 1
if (H == A and W == B) or (H == A / 2 and W == B / 2):
cnt = +1
print(int(cnt))
| Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Print the answer.
* * * | s112380613 | Accepted | p03193 | Input is given from Standard Input in the following format:
N H W
A_1 B_1
A_2 B_2
:
A_N B_N | # JMD
# Nagendra Jha-4096
import sys
import math
# import fractions
# import numpy
###File Operations###
fileoperation = 0
if fileoperation:
orig_stdout = sys.stdout
orig_stdin = sys.stdin
inputfile = open("W:/Competitive Programming/input.txt", "r")
outputfile = open("W:/Competitive Programming/output.txt", "w")
sys.stdin = inputfile
sys.stdout = outputfile
###Defines...###
mod = 1000000007
###FUF's...###
def nospace(l):
ans = "".join(str(i) for i in l)
return ans
##### Main ####
t = 1
for tt in range(t):
# n=int(input())
# a=list(map(int,sys.stdin.readline().split(' ')))
n, h, w = map(int, sys.stdin.readline().split(" "))
ans = 0
for i in range(n):
a, b = map(int, sys.stdin.readline().split(" "))
if a >= h and b >= w:
ans += 1
print(ans)
#####File Operations#####
if fileoperation:
sys.stdout = orig_stdout
sys.stdin = orig_stdin
inputfile.close()
outputfile.close()
| Statement
There are N rectangular plate materials made of special metal called AtCoder
Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically
and B_i horizontally).
Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are
exactly H \times W. He is trying to obtain such a plate by choosing one of the
N materials and cutting it if necessary. When cutting a material, the cuts
must be parallel to one of the sides of the material. Also, the materials have
fixed directions and cannot be rotated. For example, a 5 \times 3 material
cannot be used as a 3 \times 5 plate.
Out of the N materials, how many can produce an H \times W plate if properly
cut? | [{"input": "3 5 2\n 10 3\n 5 2\n 2 5", "output": "2\n \n\nTakahashi wants a 5 \\times 2 plate.\n\n * The dimensions of the first material are 10 \\times 3. We can obtain a 5 \\times 2 plate by properly cutting it.\n * The dimensions of the second material are 5 \\times 2. We can obtain a 5 \\times 2 plate without cutting it.\n * The dimensions of the third material are 2 \\times 5. We cannot obtain a 5 \\times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5 \\times 2 plate.\n\n* * *"}, {"input": "10 587586158 185430194\n 894597290 708587790\n 680395892 306946994\n 590262034 785368612\n 922328576 106880540\n 847058850 326169610\n 936315062 193149191\n 702035777 223363392\n 11672949 146832978\n 779291680 334178158\n 615808191 701464268", "output": "8"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.