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 there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s392872292 | Wrong Answer | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | n = int(input())
x = [0]*n
y = [0]*n
ux = [0]*n
uy = [0]*n
for i in range(n):
px,py,u = input().split()
if u=="U":
uy[i] =1
elif u=="R":
ux[i] =1
elif u=="D":
uy[i] =-1
elif u=="L":
ux[i] =-1
x[i]= int(px)
y[i]= int(py)
time = 2*10**7
for i in range(n):
for j in range(n-1-i):
if x[i]-x[i+1+j] == 0 and y[i]-y[i+1+j] == 0:
time = min(time,0)
elif x[i]-x[i+1+j] == 0 and not uy[i]==0 and not uy[i+1+j]==0 and not uy[i+1+j]== uy[i]:
if (y[i]-y[i+1+j])<0 and uy[i]>0:
time = min(time,abs((y[i]-y[i+1+j])/0.2))
elif (y[i]-y[i+1+j])>0 and uy[i]<0:
time = min(time,abs((y[i]-y[i+1+j])/0.2))
elif y[i]-y[i+1+j] == 0 and not ux[i]==0 and not ux[i+1+j]==0 and not ux[i+1+j]== uy[i]:
if (x[i] - x[i + 1 + j]) < 0 and ux[i] > 0:
time = min(time,abs((x[i]-x[i+1+j])/0.2))
elif (x[i] - x[i + 1 + j]) > 0 and ux[i] < 0:
time = min(time,abs((x[i]-x[i+1+j])/0.2))
elif (ux[i]-ux[i+1+j])==0 or (uy[i]-uy[i+1+j])==0:
time =time
elif (x[i]-x[i+1+j]) ==(y[i]-y[i+1+j]) and (ux[i]-ux[i+1+j]) ==(uy[i]-uy[i+1+j]):
time = min(time,abs((x[i]-x[i+1+j])/0.1))
elif (x[i]-x[i+1+j]) ==-(y[i]-y[i+1+j]) and (ux[i]-ux[i+1+j]) ==-(uy[i]-uy[i+1+j]):
time = min(time,abs((x[i]-x[i+1+j])/0.1))
if time == 2*10**7:
print("SAFE")
else:
print(int(time))
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s846057217 | Wrong Answer | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | n = int(input())
f = list()
m = 10**9
x = input()
x0 = x.split()
f += x0
for i in range(n - 1):
x = input()
x0 = x.split()
if x0[2] == "U":
for l in range(i + 1):
if (
f[3 * l + 2] == "D"
and x0[0] == f[3 * l]
and int(x0[1]) < int(f[3 * l + 1])
):
m1 = (int(f[3 * l + 1]) - int(x0[1])) * 5
if m1 < m:
m = m1
if (
f[3 * l + 2] == "R"
and int(x0[0]) - int(f[3 * l]) == int(f[3 * l + 1]) - int(x0[1])
and int(x0[0]) - int(f[3 * l]) > 0
):
m1 = (int(x0[0]) - int(f[3 * l])) * 10
if m1 < m:
m = m1
if (
f[3 * l + 2] == "L"
and int(f[3 * l]) - int(x0[0]) == int(f[3 * l + 1]) - int(x0[1])
and int(x0[0]) - int(f[3 * l]) < 0
):
m1 = (int(f[3 * l]) - int(x0[0])) * 10
if m1 < m:
m = m1
if x0[2] == "D":
for l in range(i + 1):
if (
f[3 * l + 2] == "U"
and x0[0] == f[3 * l]
and int(x0[1]) > int(f[3 * l + 1])
):
m1 = (int(f[3 * l + 1]) - int(x0[1])) * 5 * (-1)
if m1 < m:
m = m1
if (
f[3 * l + 2] == "R"
and int(x0[0]) - int(f[3 * l])
== (int(f[3 * l + 1]) - int(x0[1])) * (-1)
and int(x0[0]) - int(f[3 * l]) > 0
):
m1 = (int(x0[0]) - int(f[3 * l])) * 10
if m1 < m:
m = m1
if (
f[3 * l + 2] == "L"
and int(f[3 * l]) - int(x0[0])
== (int(f[3 * l + 1]) - int(x0[1])) * (-1)
and int(x0[0]) - int(f[3 * l]) < 0
):
m1 = (int(f[3 * l]) - int(x0[0])) * 10
if m1 < m:
m = m1
if x0[2] == "R":
for l in range(i + 1):
if (
f[3 * l + 2] == "L"
and int(x0[0]) < int(f[3 * l])
and int(x0[1]) == int(f[3 * l + 1])
):
m1 = (int(f[3 * l]) - int(x0[0])) * 5
if m1 < m:
m = m1
if (
f[3 * l + 2] == "U"
and (int(x0[0]) - int(f[3 * l])) * (-1)
== (int(f[3 * l + 1]) - int(x0[1]))
and int(x0[0]) - int(f[3 * l]) < 0
):
m1 = (int(x0[0]) - int(f[3 * l])) * (-1) * 10
if m1 < m:
m = m1
if (
f[3 * l + 2] == "D"
and int(f[3 * l]) - int(x0[0]) == int(f[3 * l + 1]) - int(x0[1])
and int(x0[0]) - int(f[3 * l]) < 0
):
m1 = (int(f[3 * l]) - int(x0[0])) * 10
if m1 < m:
m = m1
if x0[2] == "L":
for l in range(i + 1):
if (
f[3 * l + 2] == "R"
and int(x0[0]) > int(f[3 * l])
and int(x0[1]) == int(f[3 * l + 1])
):
m1 = (int(f[3 * l]) - int(x0[0])) * 5 * (-1)
if m1 < m:
m = m1
if (
f[3 * l + 2] == "U"
and (int(x0[0]) - int(f[3 * l]))
== (int(f[3 * l + 1]) - int(x0[1])) * (-1)
and int(x0[0]) - int(f[3 * l]) > 0
):
m1 = (int(x0[0]) - int(f[3 * l])) * 10
if m1 < m:
m = m1
if (
f[3 * l + 2] == "D"
and (int(f[3 * l]) - int(x0[0])) * (-1)
== int(f[3 * l + 1]) - int(x0[1])
and int(x0[0]) - int(f[3 * l]) > 0
):
m1 = (int(f[3 * l]) - int(x0[0])) * (-1) * 10
if m1 < m:
m = m1
f += x0
if m == 10**9:
print("SAFE")
else:
print(m)
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s161868101 | Wrong Answer | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | from itertools import combinations
INF = 10**9
time = INF
N = int(input())
A = [input().split(" ") for _ in range(N)]
if N == 1:
print("SAFE")
else:
for a, b in combinations(A, 2):
if a[2] == b[2]:
continue
elif a[2] in ("U", "D") and b[2] in ("U", "D"):
if a[0] == b[0]:
time = min(abs(int(a[1]) - int(b[1])) / 2, time)
elif a[2] in ("R", "L") and b[2] in ("R", "L"):
if a[1] == b[1]:
time = min(abs(int(a[0]) - int(b[0])) / 2, time)
elif a[2] == "R" and b[2] == "D":
if int(a[0]) < int(b[0]) and int(a[1]) < int(b[1]):
if abs(int(a[0]) - int(b[0])) == abs(int(a[1]) - int(b[1])):
time = min(abs(int(a[0]) - int(b[0])), time)
elif a[2] == "R" and b[2] == "U":
if int(a[0]) < int(b[0]) and int(a[1]) > int(b[1]):
if abs(int(a[0]) - int(b[0])) == abs(int(a[1]) - int(b[1])):
time = min(abs(int(a[0]) - int(b[0])), time)
elif a[2] == "L" and b[2] == "D":
if int(a[0]) > int(b[0]) and int(a[1]) < int(b[1]):
if abs(int(a[0]) - int(b[0])) == abs(int(a[1]) - int(b[1])):
time = min(abs(int(a[0]) - int(b[0])), time)
elif a[2] == "L" and b[2] == "U":
if int(a[0]) > int(b[0]) and int(a[1]) > int(b[1]):
if abs(int(a[0]) - int(b[0])) == abs(int(a[1]) - int(b[1])):
time = min(abs(int(a[0]) - int(b[0])), time)
elif a[2] == "U" and b[2] == "R":
if int(a[0]) > int(b[0]) and int(a[1]) < int(b[1]):
if abs(int(a[0]) - int(b[0])) == abs(int(a[1]) - int(b[1])):
time = min(abs(int(a[0]) - int(b[0])), time)
elif a[2] == "U" and b[2] == "L":
if int(a[0]) < int(b[0]) and int(a[1]) < int(b[1]):
if abs(int(a[0]) - int(b[0])) == abs(int(a[1]) - int(b[1])):
time = min(abs(int(a[0]) - int(b[0])), time)
elif a[2] == "D" and b[2] == "R":
if int(a[0]) > int(b[0]) and int(a[1]) > int(b[1]):
if abs(int(a[0]) - int(b[0])) == abs(int(a[1]) - int(b[1])):
time = min(abs(int(a[0]) - int(b[0])), time)
elif a[2] == "D" and b[2] == "L":
if int(a[0]) < int(b[0]) and int(a[1]) > int(b[1]):
if abs(int(a[0]) - int(b[0])) == abs(int(a[1]) - int(b[1])):
time = min(abs(int(a[0]) - int(b[0])), time)
if time == INF:
print("SAFE")
else:
print(time * 10 // 10)
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s121347448 | Runtime Error | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | n = int(input())
Lu = []
Lr = []
Ld = []
Ll = []
a = 400000
for i in range(n):
t = list(map(str, input().split()))
if t[2] == "U":
Lu.append(t)
elif t[2] == "R":
Lr.append(t)
elif t[2] == "D":
Ld.append(t)
elif t[2] == "L":
Ll.append(t)
# print(Lu,Lr,Ld,Ll)
def check(L1, L2, a):
if (L1[0][2] == "U" or L1[0][2] == "D") and (L2[0][2] == "U" or L2[0][2] == "D"):
for i in range(len(L1)):
for j in range(len(L2)):
if L1[i][0] == L2[i][0]:
if (L1[i][1] < L2[i][1] and L1[i][2] == "U") or (
L1[i][1] > L2[i][1] and L1[i][2] == "D"
):
t = abs(int(L1[i][1]) - int(L2[i][1])) // 2
if a > t:
a = t
elif (L1[0][2] == "L" or L1[0][2] == "R") and (L2[0][2] == "L" or L2[0][2] == "R"):
for i in range(len(L1)):
for j in range(len(L2)):
if L1[i][1] == L2[i][1]:
if (L1[i][0] < L2[i][0] and L1[i][2] == "R") or (
L1[i][0] > L2[i][0] and L1[i][2] == "L"
):
t = abs(int(L1[i][0]) - int(L2[i][0])) // 2
if a > t:
a = t
else:
for i in range(len(L1)):
for j in range(len(L2)):
if abs(int(L1[i][0]) - int(L2[i][0])) == abs(
int(L1[i][1]) - int(L2[i][1])
):
t = abs(int(L1[i][0]) - int(L2[i][0]))
if L1[i][2] == "U" and (
(L2[i][2] == "R" and L2[i][0] < L1[i][0])
or (L2[i][2] == "L" and L2[i][0] > L1[i][0])
):
if a > t:
a = t
elif L1[i][2] == "D" and (
(L2[i][2] == "R" and L2[i][0] < L1[i][0])
or (L2[i][2] == "L" and L2[i][0] > L1[i][0])
):
if a > t:
a = t
elif L1[i][2] == "R" and (
(L2[i][2] == "U" and L2[i][1] < L1[i][1])
or (L2[i][2] == "D" and L2[i][1] > L1[i][1])
):
if a > t:
a = t
elif L1[i][2] == "L" and (
(L2[i][2] == "U" and L2[i][1] > L1[i][1])
or (L2[i][2] == "D" and L2[i][1] < L1[i][1])
):
if a > t:
a = t
return a
a = check(Lu, Lr, a)
a = check(Lu, Ld, a)
a = check(Lu, Ll, a)
a = check(Lr, Ld, a)
a = check(Lr, Ll, a)
a = check(Ld, Ll, a)
if a < 400000:
print(a * 10)
else:
print("SAFE")
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s322117410 | Wrong Answer | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | n = int(input())
from collections import defaultdict
ux = set([])
uy = defaultdict(list)
dx = set([])
dy = defaultdict(list)
ry = set([])
rx = defaultdict(list)
ly = set([])
lx = defaultdict(list)
# 切片
brd = set([])
brd_dic = defaultdict(list)
blu = set([])
blu_dic = defaultdict(list)
bru = set([])
bru_dic = defaultdict(list)
bld = set([])
bld_dic = defaultdict(list)
for _ in range(n):
x, y, u = map(str, input().split())
x = int(x)
y = int(y)
if u == "U":
ux.add(x)
uy[x].append(y)
blu.add(y - x)
blu_dic[y - x].append(x)
bru.add(y + x)
bru_dic[y + x].append(x)
elif u == "D":
dx.add(x)
dy[x].append(y)
bld.add(y + x)
bld_dic[y + x].append(x)
brd.add(y - x)
brd_dic[y - x].append(x)
elif u == "R":
ry.add(y)
rx[y].append(x)
bru.add(y + x)
bru_dic[y + x].append(x)
brd.add(y - x)
brd_dic[y - x].append(x)
else:
ly.add(y)
lx[y].append(x)
blu.add(y - x)
blu_dic[y - x].append(x)
bld.add(y + x)
bld_dic[y + x].append(x)
ans = 10**12
###UDをチェック
for x in ux:
# x座標が同じだとぶつかる可能性がある
if x in dx:
for uy1 in uy[x]:
for dy1 in dy[x]:
if uy1 < dy1 and (dy1 - uy1) % 2 == 0:
ans = min(ans, (dy1 - uy1) // 2)
###RLをチェック
for y in ry:
# x座標が同じだとぶつかる可能性がある
if y in ly:
for rx1 in rx[y]:
for lx1 in lx[y]:
if rx1 < lx1 and (lx1 - rx1) % 2 == 0:
ans = min(ans, (lx1 - rx1) // 2)
#####
for b in blu:
tmp = blu_dic[b]
for i in range(len(tmp) - 1):
for j in range(len(tmp)):
if abs(tmp[i] - tmp[j]) % 2 == 0 and tmp[i] != tmp[j]:
ans = min(ans, abs(tmp[i] - tmp[j]))
for b in bld:
tmp = bld_dic[b]
for i in range(len(tmp) - 1):
for j in range(len(tmp)):
if abs(tmp[i] - tmp[j]) % 2 == 0 and tmp[i] != tmp[j]:
ans = min(ans, abs(tmp[i] - tmp[j]))
for b in brd:
tmp = brd_dic[b]
for i in range(len(tmp) - 1):
for j in range(len(tmp)):
if abs(tmp[i] - tmp[j]) % 2 == 0 and tmp[i] != tmp[j]:
ans = min(ans, abs(tmp[i] - tmp[j]))
for b in bld:
tmp = bld_dic[b]
for i in range(len(tmp) - 1):
for j in range(len(tmp)):
if abs(tmp[i] - tmp[j]) % 2 == 0 and tmp[i] != tmp[j]:
ans = min(ans, abs(tmp[i] - tmp[j]))
if ans == 10**12:
print("SAFE")
else:
print(ans * 10)
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s846359039 | Wrong Answer | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | N = int(input())
XYU = []
for _ in range(N):
line = list(input().split())
line[0] = int(line[0])
line[1] = int(line[1])
XYU.append(line)
# print(XYU)
def get_unique_list(seq):
seen = []
return [x for x in seq if x not in seen and not seen.append(x)]
for time in range(1, 2 * (10**5) + 1):
xy = []
for i in XYU:
if i[2] == "R":
i[0] += 1
elif i[2] == "U":
i[1] += 1
elif i[2] == "L":
i[0] -= 1
elif i[2] == "D":
i[1] -= 1
xy.append(i[0:2])
if len(get_unique_list(xy)) != N:
print(time * 10)
exit()
print("SAFE")
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
Print the maximum possible number of squares lighted by the lamp.
* * * | s040314307 | Runtime Error | p03014 | Input is given from Standard Input in the following format:
H W
S_1
:
S_H | H, W = map(int, input().split())
S = [["x"] * W] * H
for h in range(H):
S[h] = list(input())
# print(S)
def pmap(func):
return func()
def hmap():
for h in range(H):
bw, sw = 0, 0
for i in range(W):
if S[h][i] != "#" and i != W - 1:
bw += 1
elif S[h][i] == "#":
for asw in range(sw, i):
S[h][asw] = bw
bw = 0
sw = i + 1
# print(sw,bw)
elif i == W - 1:
bw += 1
# print('err')
for asw in range(sw, W):
S[h][asw] = bw
return S
# print('2nd')
# print(S)
def wmap():
for w in range(W):
bh, sh = 0, 0
for i in range(H):
if S[i][w] != "#" and i != H - 1:
bh += 1
elif S[i][w] == "#":
for ash in range(sh, i):
S[ash][w] = bh
bh = 0
sh = i + 1
# print(sh,bh)
elif i == H - 1:
bh += 1
# print('err')
for ash in range(sh, H):
S[ash][w] = bh
return S
# print(S)
import itertools
from concurrent.futures import ProcessPoolExecutor as PPE
with PPE(max_workers=2) as exe:
Ss = []
for aS in exe.map(pmap, [hmap, wmap]):
Ss.append(list(itertools.chain.from_iterable(aS)))
r = 0
for s1, s2 in zip(Ss[0], Ss[1]):
if str(s1).isdecimal():
r = max(r, s1 + s2)
print(r - 1)
| Statement
There is a grid with H horizontal rows and W vertical columns, and there are
obstacles on some of the squares.
Snuke is going to choose one of the squares not occupied by an obstacle and
place a lamp on it. The lamp placed on the square will emit straight beams of
light in four cardinal directions: up, down, left, and right. In each
direction, the beam will continue traveling until it hits a square occupied by
an obstacle or it hits the border of the grid. It will light all the squares
on the way, including the square on which the lamp is placed, but not the
square occupied by an obstacle.
Snuke wants to maximize the number of squares lighted by the lamp.
You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th
character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square
at the i-th row from the top and the j-th column from the left; if that
character is `.`, there is no obstacle on that square.
Find the maximum possible number of squares lighted by the lamp. | [{"input": "4 6\n #..#..\n .....#\n ....#.\n #.#...", "output": "8\n \n\nIf Snuke places the lamp on the square at the second row from the top and the\nsecond column from the left, it will light the following squares: the first\nthrough fifth squares from the left in the second row, and the first through\nfourth squares from the top in the second column, for a total of eight\nsquares.\n\n* * *"}, {"input": "8 8\n ..#...#.\n ....#...\n ##......\n ..###..#\n ...#..#.\n ##....#.\n #...#...\n ###.#..#", "output": "13"}] |
Print the maximum possible number of squares lighted by the lamp.
* * * | s609764576 | Runtime Error | p03014 | Input is given from Standard Input in the following format:
H W
S_1
:
S_H | line = input().split()
N = int(line[0])
M = int(line[1])
broken = []
count = 0
step = []
def check(value):
if count < M:
return broken[count] == value
else:
return False
for i in range(M):
a = int(input())
broken += [a]
if check(1):
step += [0]
count += 1
else:
step += [1]
if check(2):
step += [0]
count += 1
else:
step += [1 + step[0]]
for j in range(2, N):
if check(j + 1):
step += [0]
count += 1
else:
step += [step[j - 2] + step[j - 1]]
ans = step[N - 1] % (10 ^ 9 + 7)
print(ans)
| Statement
There is a grid with H horizontal rows and W vertical columns, and there are
obstacles on some of the squares.
Snuke is going to choose one of the squares not occupied by an obstacle and
place a lamp on it. The lamp placed on the square will emit straight beams of
light in four cardinal directions: up, down, left, and right. In each
direction, the beam will continue traveling until it hits a square occupied by
an obstacle or it hits the border of the grid. It will light all the squares
on the way, including the square on which the lamp is placed, but not the
square occupied by an obstacle.
Snuke wants to maximize the number of squares lighted by the lamp.
You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th
character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square
at the i-th row from the top and the j-th column from the left; if that
character is `.`, there is no obstacle on that square.
Find the maximum possible number of squares lighted by the lamp. | [{"input": "4 6\n #..#..\n .....#\n ....#.\n #.#...", "output": "8\n \n\nIf Snuke places the lamp on the square at the second row from the top and the\nsecond column from the left, it will light the following squares: the first\nthrough fifth squares from the left in the second row, and the first through\nfourth squares from the top in the second column, for a total of eight\nsquares.\n\n* * *"}, {"input": "8 8\n ..#...#.\n ....#...\n ##......\n ..###..#\n ...#..#.\n ##....#.\n #...#...\n ###.#..#", "output": "13"}] |
Print the maximum possible number of squares lighted by the lamp.
* * * | s694574778 | Runtime Error | p03014 | Input is given from Standard Input in the following format:
H W
S_1
:
S_H | # 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
def read_a_int():
return int(read())
def read_matrix(H):
"""
H is number of rows
"""
return [list(map(int, read().split())) for _ in range(H)]
def read_map(H):
"""
H is number of rows
文字列で与えられた盤面を読み取る用
"""
return [read()[:-1] for _ in range(H)]
def read_col(H, n_cols):
"""
H is number of rows
n_cols is number of cols
A列、B列が与えられるようなとき
"""
ret = [[] for _ in range(n_cols)]
for _ in range(H):
tmp = list(map(int, read().split()))
for col in range(n_cols):
ret[col].append(tmp[col])
return ret
def full(shape, full_value):
if isinstance(shape, tuple):
sha = shape[::-1]
ret = [full_value] * sha[0]
for s in sha[1:]:
ret = [ret.copy() for i in range(s)]
return ret
else:
return [full_value] * shape
H, W = read_ints()
S = read_map(H)
# まわりを壁でfill
MAP = ["#" * (W + 2)]
for s in S:
MAP.append("#" + s + "#")
MAP.append("#" * (W + 2))
tate = full((H + 2, W + 2), 0)
yoko = full((H + 2, W + 2), 0)
# yokoの構築
for i in range(H + 2):
pre = "#"
for j in range(1, W + 2):
if pre == "#" and MAP[i][j] == ".":
s = j
pre = "."
if pre == "." and MAP[i][j] == "#":
t = j
cnt = t - s
pre = "#"
for k in range(s, t):
yoko[i][k] = cnt
# tateの構築
for j in range(W + 2):
pre = "#"
for i in range(1, H + 2):
if pre == "#" and MAP[i][j] == ".":
s = i
pre = "."
if pre == "." and MAP[i][j] == "#":
t = i
cnt = t - s
pre = "#"
for k in range(s, t):
tate[k][j] = cnt
ans = 0
from itertools import product
for i, j in product(range(H + 2), range(W + 2)):
if MAP[i][j] == "#":
continue
ans = max(ans, tate[i][j] + yoko[i][j] - 1)
print(ans)
| Statement
There is a grid with H horizontal rows and W vertical columns, and there are
obstacles on some of the squares.
Snuke is going to choose one of the squares not occupied by an obstacle and
place a lamp on it. The lamp placed on the square will emit straight beams of
light in four cardinal directions: up, down, left, and right. In each
direction, the beam will continue traveling until it hits a square occupied by
an obstacle or it hits the border of the grid. It will light all the squares
on the way, including the square on which the lamp is placed, but not the
square occupied by an obstacle.
Snuke wants to maximize the number of squares lighted by the lamp.
You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th
character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square
at the i-th row from the top and the j-th column from the left; if that
character is `.`, there is no obstacle on that square.
Find the maximum possible number of squares lighted by the lamp. | [{"input": "4 6\n #..#..\n .....#\n ....#.\n #.#...", "output": "8\n \n\nIf Snuke places the lamp on the square at the second row from the top and the\nsecond column from the left, it will light the following squares: the first\nthrough fifth squares from the left in the second row, and the first through\nfourth squares from the top in the second column, for a total of eight\nsquares.\n\n* * *"}, {"input": "8 8\n ..#...#.\n ....#...\n ##......\n ..###..#\n ...#..#.\n ##....#.\n #...#...\n ###.#..#", "output": "13"}] |
Print the maximum possible number of squares lighted by the lamp.
* * * | s331061411 | Runtime Error | p03014 | Input is given from Standard Input in the following format:
H W
S_1
:
S_H | H, W = [int(_) for _ in input().split()]
S = []
for _ in range(H):
S += [1 if _ == "." else 0 for _ in list(input())]
S += [0] * W
SL = S.copy()
SR = S.copy()
SU = S.copy()
SD = S.copy()
for h in range(H):
for i in range(W * h + 1, W * (h + 1)):
if SL[i]:
SL[i] = SL[i - 1] + 1
else:
SL[i] = 0
for h in range(H):
for i in range(W * h - 2, W * (h - 1) - 1, -1):
if SR[i]:
SR[i] = SR[i + 1] + 1
else:
SR[i] = 0
for w in range(W):
for i in range(W + w, W * H + w, W):
if SU[i]:
SU[i] = SU[i - W] + 1
else:
SU[i] = 0
for w in range(W):
for i in range(W * (H - 2) + w - 1, -1, -W):
if SD[i]:
SD[i] = SD[i + W] + 1
else:
SD[i] = 0
score = 0
print(max((SL[_] + SR[_] + SU[_] + SD[_] - 3 for _ in range(H * W))))
| Statement
There is a grid with H horizontal rows and W vertical columns, and there are
obstacles on some of the squares.
Snuke is going to choose one of the squares not occupied by an obstacle and
place a lamp on it. The lamp placed on the square will emit straight beams of
light in four cardinal directions: up, down, left, and right. In each
direction, the beam will continue traveling until it hits a square occupied by
an obstacle or it hits the border of the grid. It will light all the squares
on the way, including the square on which the lamp is placed, but not the
square occupied by an obstacle.
Snuke wants to maximize the number of squares lighted by the lamp.
You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th
character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square
at the i-th row from the top and the j-th column from the left; if that
character is `.`, there is no obstacle on that square.
Find the maximum possible number of squares lighted by the lamp. | [{"input": "4 6\n #..#..\n .....#\n ....#.\n #.#...", "output": "8\n \n\nIf Snuke places the lamp on the square at the second row from the top and the\nsecond column from the left, it will light the following squares: the first\nthrough fifth squares from the left in the second row, and the first through\nfourth squares from the top in the second column, for a total of eight\nsquares.\n\n* * *"}, {"input": "8 8\n ..#...#.\n ....#...\n ##......\n ..###..#\n ...#..#.\n ##....#.\n #...#...\n ###.#..#", "output": "13"}] |
Print the maximum possible number of squares lighted by the lamp.
* * * | s895074627 | Accepted | p03014 | Input is given from Standard Input in the following format:
H W
S_1
:
S_H | h, *s = open(0)
h, w = map(int, h.split())
r = range
a, b, c, d = [[[0] * w for _ in r(h)] for i in r(4)]
for i in r(h * w):
i, j = i // w, i % w
a[i][j] = -~a[i][j - 1] * (s[i][j] == ".")
b[i][~j] = -~b[i][-j] * (s[i][-j - 2] == ".")
c[i][j] = -~c[i - 1][j] * (s[i][j] == ".")
d[~i][j] = -~d[-i][j] * (s[~i][j] == ".")
print(max(a[i][j] + b[i][j] + c[i][j] + d[i][j] - 3 for i in r(h) for j in r(w)))
| Statement
There is a grid with H horizontal rows and W vertical columns, and there are
obstacles on some of the squares.
Snuke is going to choose one of the squares not occupied by an obstacle and
place a lamp on it. The lamp placed on the square will emit straight beams of
light in four cardinal directions: up, down, left, and right. In each
direction, the beam will continue traveling until it hits a square occupied by
an obstacle or it hits the border of the grid. It will light all the squares
on the way, including the square on which the lamp is placed, but not the
square occupied by an obstacle.
Snuke wants to maximize the number of squares lighted by the lamp.
You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th
character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square
at the i-th row from the top and the j-th column from the left; if that
character is `.`, there is no obstacle on that square.
Find the maximum possible number of squares lighted by the lamp. | [{"input": "4 6\n #..#..\n .....#\n ....#.\n #.#...", "output": "8\n \n\nIf Snuke places the lamp on the square at the second row from the top and the\nsecond column from the left, it will light the following squares: the first\nthrough fifth squares from the left in the second row, and the first through\nfourth squares from the top in the second column, for a total of eight\nsquares.\n\n* * *"}, {"input": "8 8\n ..#...#.\n ....#...\n ##......\n ..###..#\n ...#..#.\n ##....#.\n #...#...\n ###.#..#", "output": "13"}] |
Print the maximum possible number of squares lighted by the lamp.
* * * | s915666807 | Accepted | p03014 | Input is given from Standard Input in the following format:
H W
S_1
:
S_H | # D - Lamp
# import numpy as np
H, W = map(int, input().split())
# S = np.array([list(input()) for _ in range(H)])
S = [list(input()) for _ in range(H)]
def trans(M):
output_list = []
for col in range(len(M[0])):
tmp = []
for row in range(len(M)):
tmp.append(M[row][col])
output_list.append(tmp)
return output_list
def n_row_lighten(l):
output_list = []
left_block_idx = -1
for idx in range(len(l)):
if l[idx] == "#":
right_block_idx = idx
for _ in range(right_block_idx - left_block_idx - 1):
output_list.append(right_block_idx - left_block_idx - 1)
output_list.append(0)
left_block_idx = right_block_idx
if idx == len(l) - 1 and l[idx] == ".":
right_block_idx = idx + 1
for _ in range(right_block_idx - left_block_idx - 1):
output_list.append(right_block_idx - left_block_idx - 1)
return output_list
def n_matrix_lighten(S):
output_list = []
for row in range(len(S)):
output_list.append(n_row_lighten(S[row]))
return output_list
# n_lighten = n_matrix_lighten(S) + np.array(n_matrix_lighten(S.T)).T - 1
ans = 0
tmp1 = n_matrix_lighten(S)
tmp2 = trans(n_matrix_lighten(trans(S)))
for row in range(H):
for col in range(W):
ans = max(ans, tmp1[row][col] + tmp2[row][col] - 1)
print(ans)
| Statement
There is a grid with H horizontal rows and W vertical columns, and there are
obstacles on some of the squares.
Snuke is going to choose one of the squares not occupied by an obstacle and
place a lamp on it. The lamp placed on the square will emit straight beams of
light in four cardinal directions: up, down, left, and right. In each
direction, the beam will continue traveling until it hits a square occupied by
an obstacle or it hits the border of the grid. It will light all the squares
on the way, including the square on which the lamp is placed, but not the
square occupied by an obstacle.
Snuke wants to maximize the number of squares lighted by the lamp.
You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th
character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square
at the i-th row from the top and the j-th column from the left; if that
character is `.`, there is no obstacle on that square.
Find the maximum possible number of squares lighted by the lamp. | [{"input": "4 6\n #..#..\n .....#\n ....#.\n #.#...", "output": "8\n \n\nIf Snuke places the lamp on the square at the second row from the top and the\nsecond column from the left, it will light the following squares: the first\nthrough fifth squares from the left in the second row, and the first through\nfourth squares from the top in the second column, for a total of eight\nsquares.\n\n* * *"}, {"input": "8 8\n ..#...#.\n ....#...\n ##......\n ..###..#\n ...#..#.\n ##....#.\n #...#...\n ###.#..#", "output": "13"}] |
Print the maximum possible number of squares lighted by the lamp.
* * * | s958257830 | Accepted | p03014 | Input is given from Standard Input in the following format:
H W
S_1
:
S_H | # メイン処理
H, W = map(int, input().split())
S = []
# 二次元配列
for _ in range(H):
a = input()
S.append(list(a))
maxlamp = 0
L = [[0] * W for i in range(H)] # 左
R = [[0] * W for i in range(H)] # 右
D = [[0] * W for i in range(H)] # 下
U = [[0] * W for i in range(H)] # 上
# L = np.zeros((H,W))
# R = np.zeros((H,W))
# D = np.zeros((H,W))
# U = np.zeros((H,W))
# Lの計算
for _h in range(H):
for _w in range(W):
if S[_h][_w] != "#":
if _w == 0:
L[_h][_w] = 1
elif _w > 0:
L[_h][_w] = L[_h][_w - 1] + 1
if _h == 0:
U[_h][_w] = 1
elif _h > 0:
U[_h][_w] = U[_h - 1][_w] + 1
for _h in range(H - 1, -1, -1):
for _w in range(W - 1, -1, -1):
if S[_h][_w] != "#":
if _w == W - 1:
R[_h][_w] = 1
elif _w < W - 1:
R[_h][_w] = R[_h][_w + 1] + 1
if _h == H - 1:
D[_h][_w] = 1
elif _h < H - 1:
D[_h][_w] = D[_h + 1][_w] + 1
tmp = L[_h][_w] + R[_h][_w] + U[_h][_w] + D[_h][_w] - 3
maxlamp = max(maxlamp, tmp)
print(maxlamp)
| Statement
There is a grid with H horizontal rows and W vertical columns, and there are
obstacles on some of the squares.
Snuke is going to choose one of the squares not occupied by an obstacle and
place a lamp on it. The lamp placed on the square will emit straight beams of
light in four cardinal directions: up, down, left, and right. In each
direction, the beam will continue traveling until it hits a square occupied by
an obstacle or it hits the border of the grid. It will light all the squares
on the way, including the square on which the lamp is placed, but not the
square occupied by an obstacle.
Snuke wants to maximize the number of squares lighted by the lamp.
You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th
character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square
at the i-th row from the top and the j-th column from the left; if that
character is `.`, there is no obstacle on that square.
Find the maximum possible number of squares lighted by the lamp. | [{"input": "4 6\n #..#..\n .....#\n ....#.\n #.#...", "output": "8\n \n\nIf Snuke places the lamp on the square at the second row from the top and the\nsecond column from the left, it will light the following squares: the first\nthrough fifth squares from the left in the second row, and the first through\nfourth squares from the top in the second column, for a total of eight\nsquares.\n\n* * *"}, {"input": "8 8\n ..#...#.\n ....#...\n ##......\n ..###..#\n ...#..#.\n ##....#.\n #...#...\n ###.#..#", "output": "13"}] |
Print the maximum possible number of squares lighted by the lamp.
* * * | s145228056 | Accepted | p03014 | Input is given from Standard Input in the following format:
H W
S_1
:
S_H | # import numpy as np
H, W = map(int, input().split())
S = [None] * H
# ans = np.zeros((H, W))
ans = [[0 for j in range(W)] for i in range(H)]
for i in range(H):
s_tmp = [-1] * W
s = input()
for j, c in enumerate(s):
if c == "#":
s_tmp[j] = 1
else:
s_tmp[j] = 0
S[i] = s_tmp
max_tmp = 0
coord = (-1, -1)
for i in range(H):
# 左から右
tmp = 0
for j in range(W):
if S[i][j] == 1:
tmp = 0
else:
tmp += 1
# ans[i, j] += tmp
ans[i][j] += tmp
# 右から左
tmp = 0
for j in reversed(range(W)):
if S[i][j] == 1:
tmp = 0
else:
tmp += 1
# ans[i, j] += tmp
ans[i][j] += tmp
# 右から左
for i in range(W):
# 上から下
tmp = 0
for j in range(H):
if S[j][i] == 1:
tmp = 0
else:
tmp += 1
# ans[j, i] += tmp
ans[j][i] += tmp
# 下から上
tmp = 0
for j in reversed(range(H)):
if S[j][i] == 1:
tmp = 0
else:
tmp += 1
# ans[j, i] += tmp
ans[j][i] += tmp
# if ans[j, i] > max_tmp:
if ans[j][i] > max_tmp:
# max_tmp = ans[j, i]
max_tmp = ans[j][i]
coord = (j, i)
score = 1
tmp_x = coord[1]
while True:
tmp_x -= 1
if tmp_x < 0:
break
if S[coord[0]][tmp_x] == 0:
score += 1
else:
break
tmp_x = coord[1]
while True:
tmp_x += 1
if tmp_x >= W:
break
if S[coord[0]][tmp_x] == 0:
score += 1
else:
break
tmp_y = coord[0]
while True:
tmp_y -= 1
if tmp_y < 0:
break
if S[tmp_y][coord[1]] == 0:
score += 1
else:
break
tmp_y = coord[0]
while True:
tmp_y += 1
if tmp_y >= H:
break
if S[tmp_y][coord[1]] == 0:
score += 1
else:
break
print(score)
| Statement
There is a grid with H horizontal rows and W vertical columns, and there are
obstacles on some of the squares.
Snuke is going to choose one of the squares not occupied by an obstacle and
place a lamp on it. The lamp placed on the square will emit straight beams of
light in four cardinal directions: up, down, left, and right. In each
direction, the beam will continue traveling until it hits a square occupied by
an obstacle or it hits the border of the grid. It will light all the squares
on the way, including the square on which the lamp is placed, but not the
square occupied by an obstacle.
Snuke wants to maximize the number of squares lighted by the lamp.
You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th
character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square
at the i-th row from the top and the j-th column from the left; if that
character is `.`, there is no obstacle on that square.
Find the maximum possible number of squares lighted by the lamp. | [{"input": "4 6\n #..#..\n .....#\n ....#.\n #.#...", "output": "8\n \n\nIf Snuke places the lamp on the square at the second row from the top and the\nsecond column from the left, it will light the following squares: the first\nthrough fifth squares from the left in the second row, and the first through\nfourth squares from the top in the second column, for a total of eight\nsquares.\n\n* * *"}, {"input": "8 8\n ..#...#.\n ....#...\n ##......\n ..###..#\n ...#..#.\n ##....#.\n #...#...\n ###.#..#", "output": "13"}] |
Print the maximum possible number of squares lighted by the lamp.
* * * | s436557768 | Runtime Error | p03014 | Input is given from Standard Input in the following format:
H W
S_1
:
S_H | # -*- coding: utf-8 -*-
def f(h, w, sl):
cnt = [[[0, 0] for _ in range(w)] for _ in range(h)]
for hi in range(h):
wi = 0
while wi < w:
if sl[hi][wi] == ".":
c = 0
wj = wi
while wj < w and sl[hi][wj] == ".":
c += 1
wj += 1
for j in range(wi, wj):
cnt[hi][j][0] = c
wi = wj
else:
wi += 1
for wi in range(h):
hi = 0
while hi < h:
if sl[hi][wi] == ".":
c = 0
hj = hi
while hj < h and sl[hj][wi] == ".":
c += 1
hj += 1
for j in range(hi, hj):
cnt[j][wi][1] = c
hi = hj
else:
hi += 1
res = -1
for hi in range(h):
for wi in range(w):
if sl[hi][wi] == ".":
r = sum(cnt[hi][wi])
res = max(res, r)
return res - 1
if __name__ == "__main__":
h, w = map(int, input().split())
sl = [input() for _ in range(h)]
print(f(h, w, sl))
# from random import choice
# for _ in range(1):
# h = 2000
# w = 2000
# sl = ["".join([choice([".","#"]) for _ in range(w)]) for _ in range(h)]
| Statement
There is a grid with H horizontal rows and W vertical columns, and there are
obstacles on some of the squares.
Snuke is going to choose one of the squares not occupied by an obstacle and
place a lamp on it. The lamp placed on the square will emit straight beams of
light in four cardinal directions: up, down, left, and right. In each
direction, the beam will continue traveling until it hits a square occupied by
an obstacle or it hits the border of the grid. It will light all the squares
on the way, including the square on which the lamp is placed, but not the
square occupied by an obstacle.
Snuke wants to maximize the number of squares lighted by the lamp.
You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th
character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square
at the i-th row from the top and the j-th column from the left; if that
character is `.`, there is no obstacle on that square.
Find the maximum possible number of squares lighted by the lamp. | [{"input": "4 6\n #..#..\n .....#\n ....#.\n #.#...", "output": "8\n \n\nIf Snuke places the lamp on the square at the second row from the top and the\nsecond column from the left, it will light the following squares: the first\nthrough fifth squares from the left in the second row, and the first through\nfourth squares from the top in the second column, for a total of eight\nsquares.\n\n* * *"}, {"input": "8 8\n ..#...#.\n ....#...\n ##......\n ..###..#\n ...#..#.\n ##....#.\n #...#...\n ###.#..#", "output": "13"}] |
Print the maximum possible number of squares lighted by the lamp.
* * * | s734255604 | Wrong Answer | p03014 | Input is given from Standard Input in the following format:
H W
S_1
:
S_H | h, w = map(int, input().split())
mp = []
h_wall = []
for i in range(h):
h_wall_l = []
l = input()
mp.append(l)
for a in range(len(l)):
if l[a] == "#":
h_wall_l.append(a)
h_wall.append(h_wall_l)
v_wall = []
for i in range(w):
vl = ""
for j in range(h):
vl += mp[j][i]
v_wall_vl = []
for a in range(len(vl)):
if vl[a] == "#":
v_wall_vl.append(a)
v_wall.append(v_wall_vl)
# h_mp=[]
# for i in h_wall:
# if len(i)!=0:
# hll=[]
# first=i[0]
# for j in range(first):
# hll.append(first)
# hll.append(-1)
# if len(i)>=2:
# for j in range(len(i)-1):
# mid=i[j+1]-i[j]-1
# for z in range(mid):
# hll.append(mid)
# hll.append(-1)
# if len(hll)<w:
# diff = w-len(hll)
# for z in range(diff):
# hll.append(diff)
# else:
# hll=[w for zz in range(w)]
# h_mp.append(hll)
# v_mp = []
# for i in v_wall:
# if len(i)!=0:
# vll=[]
# first=i[0]
# for j in range(first):
# vll.append(first)
# vll.append(-1)
# if len(i)>=2:
# for j in range(len(i)-1):
# mid=i[j+1]-i[j]-1
# for z in range(mid):
# vll.append(mid)
# vll.append(-1)
# if len(vll)<h:
# diff = h-len(vll)
# for z in range(diff):
# vll.append(diff)
# else:
# vll=[h for zz in range(h)]
# v_mp.append(vll)
# # for i in v_mp:
# # print(i)
# # print("---")
# v_mp = [list(x) for x in zip(*v_mp)]
# # for i in h_mp:
# # print(i)
# # print("---")
# # for i in v_mp:
# # print(i)
# maxx=0
# for i in range(h):
# for j in range(w):
# hhh = h_mp[i][j]
# vvv = v_mp[i][j]
# if hhh != -1 and vvv != -1:
# temp = hhh+vvv-1
# if temp >= maxx:
# maxx=temp
# print(maxx)
| Statement
There is a grid with H horizontal rows and W vertical columns, and there are
obstacles on some of the squares.
Snuke is going to choose one of the squares not occupied by an obstacle and
place a lamp on it. The lamp placed on the square will emit straight beams of
light in four cardinal directions: up, down, left, and right. In each
direction, the beam will continue traveling until it hits a square occupied by
an obstacle or it hits the border of the grid. It will light all the squares
on the way, including the square on which the lamp is placed, but not the
square occupied by an obstacle.
Snuke wants to maximize the number of squares lighted by the lamp.
You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th
character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square
at the i-th row from the top and the j-th column from the left; if that
character is `.`, there is no obstacle on that square.
Find the maximum possible number of squares lighted by the lamp. | [{"input": "4 6\n #..#..\n .....#\n ....#.\n #.#...", "output": "8\n \n\nIf Snuke places the lamp on the square at the second row from the top and the\nsecond column from the left, it will light the following squares: the first\nthrough fifth squares from the left in the second row, and the first through\nfourth squares from the top in the second column, for a total of eight\nsquares.\n\n* * *"}, {"input": "8 8\n ..#...#.\n ....#...\n ##......\n ..###..#\n ...#..#.\n ##....#.\n #...#...\n ###.#..#", "output": "13"}] |
Print the maximum possible number of squares lighted by the lamp.
* * * | s697238698 | Wrong Answer | p03014 | Input is given from Standard Input in the following format:
H W
S_1
:
S_H | if __name__ == "__main__":
HW = list(map(int, input().split(" ")))
H = HW[0]
W = HW[1]
List = ["" for i in range(H)]
for a in range(H):
List[a] = input()
max = 0
for A in range(H):
for B in range(W):
i = A - 4 if A - 4 > 0 else 0
j = A + 4 if A + 4 < H else H - 1
k = B - 4 if B - 4 > 0 else 0
l = B + 4 if B + 4 < W else W - 1
Count = 0
for AA in range(i, j):
if List[AA][B] == ".":
Count += 1
Count += List[A][k:l].count(".")
if max < Count:
max = Count
print(max)
| Statement
There is a grid with H horizontal rows and W vertical columns, and there are
obstacles on some of the squares.
Snuke is going to choose one of the squares not occupied by an obstacle and
place a lamp on it. The lamp placed on the square will emit straight beams of
light in four cardinal directions: up, down, left, and right. In each
direction, the beam will continue traveling until it hits a square occupied by
an obstacle or it hits the border of the grid. It will light all the squares
on the way, including the square on which the lamp is placed, but not the
square occupied by an obstacle.
Snuke wants to maximize the number of squares lighted by the lamp.
You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th
character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square
at the i-th row from the top and the j-th column from the left; if that
character is `.`, there is no obstacle on that square.
Find the maximum possible number of squares lighted by the lamp. | [{"input": "4 6\n #..#..\n .....#\n ....#.\n #.#...", "output": "8\n \n\nIf Snuke places the lamp on the square at the second row from the top and the\nsecond column from the left, it will light the following squares: the first\nthrough fifth squares from the left in the second row, and the first through\nfourth squares from the top in the second column, for a total of eight\nsquares.\n\n* * *"}, {"input": "8 8\n ..#...#.\n ....#...\n ##......\n ..###..#\n ...#..#.\n ##....#.\n #...#...\n ###.#..#", "output": "13"}] |
Print the maximum possible number of squares lighted by the lamp.
* * * | s647587801 | Runtime Error | p03014 | Input is given from Standard Input in the following format:
H W
S_1
:
S_H | import numpy as np
Height, Width = map(int, input().split(" "))
lineBlocks = [(input()) for i in range(Height)]
twoDimMap = []
for Block in lineBlocks:
twoDimMap.append(list(Block))
ansList = []
heightList = np.zeros((Height, Width), dtype=int)
widthList = np.zeros((Height, Width), dtype=int)
for i in range(Height):
for j in range(Width):
if "#" == twoDimMap[i][j]:
continue
else:
if heightList[i][j] == 0:
k_up = i + 1
height_len = 0
while k_up < Height and twoDimMap[k_up][j] != "#":
height_len += 1
k_up += 1
k_down = i - 1
while k_down >= 0 and twoDimMap[k_down][j] != "#":
height_len += 1
k_down -= 1
for k in range(k_down + 1, k_up):
heightList[k][i] = height_len
if widthList[i][j] == 0:
k_right = j + 1
width_len = 0
while k_right < Width and twoDimMap[i][k_right] != "#":
width_len += 1
k_right += 1
k_left = j - 1
while k_left >= 0 and twoDimMap[i][k_left] != "#":
width_len += 1
k_left -= 1
for k in range(k_left + 1, k_right):
widthList[i][k] = width_len
print(np.array(heightList + widthList + 1).max())
| Statement
There is a grid with H horizontal rows and W vertical columns, and there are
obstacles on some of the squares.
Snuke is going to choose one of the squares not occupied by an obstacle and
place a lamp on it. The lamp placed on the square will emit straight beams of
light in four cardinal directions: up, down, left, and right. In each
direction, the beam will continue traveling until it hits a square occupied by
an obstacle or it hits the border of the grid. It will light all the squares
on the way, including the square on which the lamp is placed, but not the
square occupied by an obstacle.
Snuke wants to maximize the number of squares lighted by the lamp.
You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th
character (1 \leq j \leq W) of S_i is `#`, there is an obstacle on the square
at the i-th row from the top and the j-th column from the left; if that
character is `.`, there is no obstacle on that square.
Find the maximum possible number of squares lighted by the lamp. | [{"input": "4 6\n #..#..\n .....#\n ....#.\n #.#...", "output": "8\n \n\nIf Snuke places the lamp on the square at the second row from the top and the\nsecond column from the left, it will light the following squares: the first\nthrough fifth squares from the left in the second row, and the first through\nfourth squares from the top in the second column, for a total of eight\nsquares.\n\n* * *"}, {"input": "8 8\n ..#...#.\n ....#...\n ##......\n ..###..#\n ...#..#.\n ##....#.\n #...#...\n ###.#..#", "output": "13"}] |
When the minimum fee is x yen, print the value of x.
* * * | s981896087 | Accepted | p03501 | Input is given from Standard Input in the following format:
N A B | #!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI():
return list(map(int, sys.stdin.readline().split()))
def I():
return int(sys.stdin.readline())
def LS():
return list(map(list, sys.stdin.readline().split()))
def S():
return list(sys.stdin.readline())[:-1]
def IR(n):
l = [None for i in range(n)]
for i in range(n):
l[i] = I()
return l
def LIR(n):
l = [None for i in range(n)]
for i in range(n):
l[i] = LI()
return l
def SR(n):
l = [None for i in range(n)]
for i in range(n):
l[i] = S()
return l
def LSR(n):
l = [None for i in range(n)]
for i in range(n):
l[i] = LS()
return l
sys.setrecursionlimit(1000000)
mod = 1000000007
# A
def A():
n, a, b = LI()
print(min(n * a, b))
return
# B
def B():
return
# C
def C():
return
# D
def D():
return
# E
def E():
return
# F
def F():
return
# G
def G():
return
# H
def H():
return
# I
def I_():
return
# J
def J():
return
# Solve
if __name__ == "__main__":
A()
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s315007677 | Accepted | p03501 | Input is given from Standard Input in the following format:
N A B | time, normal_cost, unlimited_cost = map(int, input().split())
if normal_cost * time < unlimited_cost:
total_cost = normal_cost * time
else:
total_cost = unlimited_cost
print(total_cost)
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s021172364 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | # region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import (
accumulate,
groupby,
product,
permutations,
combinations,
combinations_with_replacement,
)
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float("inf")
MOD = 10**9 + 7
PI = math.pi
# endregion
N, A, B = ri()
print(min(A * N, B))
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s111196685 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | n, c = map(int, input().split())
stc = [[int(i) for i in input().split()] for _ in range(n)]
dp = [0] * (2 * 10**5 + 2)
for s, t, c in stc:
dp[2 * s - 1] += 1
dp[2 * t] -= 1
for i in range(2 * 10**5):
dp[i + 1] += dp[i]
print(max(dp))
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s046152353 | Wrong Answer | p03501 | Input is given from Standard Input in the following format:
N A B | import time
import random
##
# DEV
NN = 17
XX = [0] * (2 ** (NN + 1) - 1)
def addvalue(j, x):
i = 2**NN + j - 1
while i >= 0:
XX[i] += x
i = (i - 1) // 2
def getvalue(j):
return XX[j + 2**NN - 1]
def rangesum(a, b):
l = a + (1 << NN)
r = b + (1 << NN)
s = 0
while l < r:
if l % 2:
s += XX[l - 1]
l += 1
if r % 2:
r -= 1
s += XX[r - 1]
l >>= 1
r >>= 1
return s
def debug():
mm = 10
tmp = [(i, XX[i + 2**NN - 1]) for i in range(2**NN) if XX[i + 2**NN - 1] != 0]
if len(tmp) <= mm:
print(tmp)
else:
print(tmp[:mm])
addvalue(3, 10)
print(rangesum(1, 12))
addvalue(5, 7)
print(rangesum(1, 12))
addvalue(13, 5)
print(rangesum(1, 12))
print(rangesum(1, 15))
debug()
print(getvalue(6))
sTime = time.time()
for i in range(10**5):
a, b = random.randrange(1 << NN), random.randrange(10**5)
# print("ADD", a, b)
# addvalue(a, b)
ii = 2**NN + a - 1
while ii >= 0:
XX[ii] += b
ii = (ii - 1) // 2
# debug()
c, d = random.randrange(1 << NN), random.randrange(1 << NN)
c, d = min(c, d), max(c, d)
# print("Sum", c, d)
# print(rangesum(c, d))
# x = rangesum(c, d)
print(time.time() - sTime, "sec")
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s621606159 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | N, C = map(int, input().split())
STC = []
for _ in range(N):
s, t, c = map(int, input().split())
STC.append([s, t, c])
STC.sort()
rs = [[STC[0][1], STC[0][2]]]
for i in range(1, N):
len_rs = len(rs)
min_idx = None
for j in range(len_rs):
if rs[j][1] != STC[i][2]:
tmp_stc_r = STC[i][0] - 0.5
else:
tmp_stc_r = STC[i][0]
if rs[j][0] <= tmp_stc_r:
if min_idx is None:
min_idx = j
else:
if rs[j][0] < rs[min_idx][0]:
min_idx = j
if min_idx is None:
rs.append([STC[i][1], STC[i][2]])
else:
rs[min_idx] = [STC[i][1], STC[i][2]]
print(len(rs))
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s518688360 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | ###==================================================
### import
# import bisect
# from collections import Counter, deque, defaultdict
# from copy import deepcopy
# from functools import reduce, lru_cache
# from heapq import heappush, heappop
# import itertools
# import math
# import string
import sys
### stdin
def input():
return sys.stdin.readline().rstrip()
def iIn():
return int(input())
def iInM():
return map(int, input().split())
def iInM1():
return map(int1, input().split())
def iInLH():
return list(map(int, input().split()))
def iInLH1():
return list(map(int1, input().split()))
def iInLV(n):
return [iIn() for _ in range(n)]
def iInLV1(n):
return [iIn() - 1 for _ in range(n)]
def iInLD(n):
return [iInLH() for _ in range(n)]
def iInLD1(n):
return [iInLH1() for _ in range(n)]
def sInLH():
return list(input().split())
def sInLV(n):
return [input().rstrip("\n") for _ in range(n)]
def sInLD(n):
return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=" "):
print(deli.join(map(str, lst)))
def OutV(lst):
print("\n".join(map(str, lst)))
### setting
sys.setrecursionlimit(10**6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------
N, A, B = iInM()
ans = min(A * N, B)
pritn(ans)
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s267876224 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | class Imos:
def __init__(self, n):
self.B = [0] * n
self.n = n
from itertools import accumulate
self.ac = accumulate
def __call__(self, l, r):
l, r = max(l, 0), min(r, self.n - 1)
self.B[l] += 1
if r + 1 != self.n:
self.B[r + 1] -= 1
def out(self):
(*res,) = self.ac(self.B)
return res
from collections import defaultdict
d = defaultdict(list)
imos = Imos(10**5 + 1)
(N, C), *D = [[*map(int, o.split())] for o in open(0)]
for s, t, c in D:
d[c] += ((s, t),)
for p in d.values():
p.sort()
ps, pt = p[0]
for s, t in p[1:] + [[0, 0]]:
if pt == s:
pt = t
else:
imos(ps, pt)
ps, pt = s, t
print(max(imos.out()))
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s134171382 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | import numpy as np
def main():
input_string = list(map(int, input().split()))
N = input_string[0]
C = input_string[1]
data = []
for i in range(N):
data.append(list(map(int, input().split())))
data_np = np.array(data).reshape(N, 3)
max_time = max(data_np[:, 1])
schedule = np.zeros([max_time, C])
for i in range(N):
start = data[i][0] - 1
end = data[i][1] - 1
channel = data[i][2] - 1
for j in range(end - start + 1):
schedule[start + j][channel] = 1
for c in range(C):
for t in range(max_time):
if t == 0:
continue
if schedule[t][c] == 1 and schedule[t - 1][c] == 0:
schedule[t - 1][c] = 1
max_N = 0
for t in range(max_time):
sum_of_ch = sum(schedule[t])
if sum_of_ch > max_N:
max_N = int(sum_of_ch)
print(max_N)
main()
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s222566781 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | N, A, B = map(int,input().split())
print(min(N*A, B) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s550265370 | Accepted | p03501 | Input is given from Standard Input in the following format:
N A B | l = list(map(int, input().split()))
print(min(l[0] * l[1], l[2]))
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s402231650 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | N = input()
print("Yes" if int(N) % (int(N[0]) + int(N[1])) == 0 else "No")
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s997960954 | Accepted | p03501 | Input is given from Standard Input in the following format:
N A B | # coding: utf-8
# user: herp_sy
def quicksort(seq):
if len(seq) < 1:
return seq
pivot = seq[0]
left = []
right = []
for x in range(1, len(seq)):
if seq[x] <= pivot:
left.append(seq[x])
else:
right.append(seq[x])
left = quicksort(left)
right = quicksort(right)
foo = [pivot]
return left + foo + right
# , = map(int, input.split())
# = int(input())
n, a, b = map(int, input().split())
if n * a < b:
print(n * a)
else:
print(b)
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s437351870 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | def binarize(txt):
xs = txt.split(" ")
xs = [int(x) for x in xs]
b = 0
for i in range(10):
b += xs[i] * (2**i)
return b
def count1(b):
b = b[2:]
count = 0
for i in range(len(b)):
if b[i] == "1":
count += 1
return count
N = input()
N = int(N)
F = [0 for i in range(N)]
for i in range(N):
txt = input()
F[i] = binarize(txt)
P = [[] for i in range(N)]
for i in range(N):
xs = input().split(" ")
P[i] = [int(x) for x in xs]
m = -(10**11)
for i in range(1, 2**10):
score = 0
for j in range(N):
b = bin(i & F[j])
count = count1(b)
score += P[j][count]
if score > m:
m = score
print(m)
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s939812505 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | N = int(input())
F = []
P = []
for _ in range(N):
F.append(list(map(int, input().split())))
for _ in range(N):
P.append(list(map(int, input().split())))
m = 2**10
gain = -(10**10)
for i in range(1, 2**10):
x = list(map(int, format(i, "b").zfill(10)))
sumP = 0
for j in range(N):
total = sum([a * b for a, b in zip(x, F[j])])
sumP += P[j][total]
gain = max(gain, sumP)
print(gain)
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s604667813 | Accepted | p03501 | Input is given from Standard Input in the following format:
N A B | [print(min(n * a, b)) for n, a, b in [map(int, input().split())]]
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s582990778 | Accepted | p03501 | Input is given from Standard Input in the following format:
N A B | st = input().split()
n = int(st[0])
a = int(st[1])
b = int(st[2])
print(min([n * a, b]))
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s720608029 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | n, a, b = (int(i) for i in input().split())
print(min(n*a, b) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s146909665 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | n,a,b=map(int,input().split())
if n*a>b:
print(b)
else n*a<=b:
print(n*a) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s417976375 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | N, A, B = map(int, input().split())
if N * A > B:
print(B)
else
print(N * A) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s513019935 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | n,a,b = map(int, input().split())
if a*n >= b:
print(b)
else:
print( | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s483429843 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | n, a, b = (int(i) for i in input().split(" "))
print(nin(a * n, b))
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s649164391 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | N,A,B=int(i) for i in input().split()
if A*N<B:
print(A*N)
else:
print(B) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s041719118 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B |
tmp = list(input()).split()
val = [int(v) for v in tmp]
if val[0] * val[1] >= val[2]:
ans = val[2]
else:
ans = val[0] * val[1] | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s449284073 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | N,A,B = map(int, input().split())
NxA = (N*A)
if NxA =< B:
print(NxA)
else:
print(B)
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s235244518 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | N,A,B= map(int,input().split(' '))
x=A*N
if x>B:
print(str(B))
elif x=B:
print(str(B))
else ;
print(str(x)) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s730529418 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | list = [int(i) for i in input().split()]
fee = list[0] * list[1]
print(min(fee, list[2]) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s106507005 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | n,a,b=[int(i) for i in input().split()]
x=A*N
if x>=B:
print(str(B))
else ;
print(str(x))
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s517176903 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | N,A,B = map(int, input().split())
NxA = (N*B)
if NxA =< B:
print(NxA)
else:
print(B)
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s570592055 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | st=input().split()
N=int(st[0]);A=int(st[1]);B=int(st[2])
print("{0}".format(min(A*N,B)) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s000780425 | Wrong Answer | p03501 | Input is given from Standard Input in the following format:
N A B | def charge(N, A, B):
plan1 = N * A
plan2 = B
if plan1 < plan2:
return plan1
else:
return plan2
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s203687140 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | N,A,B= map(int,input().split(' '))
x=A*N
if x>B:
print(B)
elif x=B:
print(B)
else ;
print(x) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s091951112 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | st=input().split()
N=int(st[0]);A=int(st[1]);B=int(st[2]);
print("{0}".format(min(A*N,B)) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s702772779 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | N=int(input()) A=int(input()) B=int(input())
v_fee=N*A
f_fee=B
data=[v_fee, f_fee]
dmin=min(data)
print(dmin) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s297392949 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | n,a,b = map(int, input().split())
print(min(n*a,b) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s747766646 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | N,A,B = map(int,input().split())
print(min(N*A,B) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s398028845 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | n, a, b = map(int, input().split()), print(min(n * a, b))
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s168998633 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | a,b,c=map(int,input().split())
print(min(a*b,c) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s942342378 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | N,A,B=map(int, input().split())
print(min(N*A, B) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s189951067 | Accepted | p03501 | Input is given from Standard Input in the following format:
N A B | A, B, C = map(int, input().split())
print(min(A * B, C))
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s255650339 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | n, a, b = map(int, input().split())
print(min(n*a, b))
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s415129077 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | s = input()
print("No" if int(s) % sum(map(int, s)) else "Yes")
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s210374774 | Accepted | p03501 | Input is given from Standard Input in the following format:
N A B | #!/usr/bin/python3
# vim: set fileencoding=utf-8:
import sys
input = sys.stdin.readline
"""
H = int(input())
h = [int(ele) for ele in input().split()]
h = [0] + h
"""
def main():
N, A, B = map(int, input().split())
print(min(B, N * A))
def bfs(queue):
global yet, graph
if len(queue) == 0:
return
yet.remove(queue[-1])
for i, adjacency in enumerate(graph[queue[-1]]):
if (
adjacency == 1 and (i in yet) and (i not in queue)
): # 隣接かつ未探索であれば、stackにpush
queue.appendleft(i)
else:
queue.pop()
bfs(queue)
def dfs(stack):
global yet, graph
yet.remove(stack[-1])
for i, adjacency in enumerate(graph[stack[-1]]):
if adjacency == 1 and i in yet: # 隣接かつ未探索であれば、stackにpush
stack.append(i)
dfs(stack)
else:
stack.pop()
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
class Node:
def __init__(self):
self.idx = None
self.left = None
self.right = None
self.parent = None
return
def pre_order(self):
global pre_order_str
pre_order_str += str(self.idx) + " "
if self.left:
self.left.pre_order()
if self.right:
self.right.pre_order()
def in_order(self):
global in_order_str
if self.left:
self.left.in_order()
in_order_str += str(self.idx) + " "
if self.right:
self.right.in_order()
def post_order(self):
global post_order_str
if self.left:
self.left.post_order()
if self.right:
self.right.post_order()
post_order_str += str(self.idx) + " "
class HeapHelper:
"""HeapContrler.
完全二分木を二分ヒープで表現した配列 A に対して、
HeapHelper.parent(idx) とするとそのノードの親の添字を返す
存在しない場合は Falseを返す
Returns:
[type] -- [description]
"""
def __init__(self):
return
@staticmethod
def parent(i):
if i == 1:
return False
return int(i / 2)
@staticmethod
def left(i):
l_idx = 2 * i
if H < l_idx:
return False
return l_idx
@staticmethod
def right(i):
r_idx = 2 * i + 1
if H < r_idx:
return False
return r_idx
if __name__ == "__main__":
main()
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s654307216 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | n = int(input())
F = [[0] * 10 for i in range(n)]
for i in range(n):
F[i] = list(map(int, input().split()))
P = [[0] * 11 for i in range(n)]
for i in range(n):
P[i] = list(map(int, input().split()))
ans = -(10**10)
for i in range(1, 1024):
s = format(i, "12b")
A = []
for j in range(10):
if s[-1 - j] == "1":
A.append(j)
p = 0
for j in range(n):
c = sum(F[j][A[k]] for k in range(len(A)))
p = p + P[j][c]
if p > ans:
ans = p
print(ans)
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s416091717 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | N, C = map(int, input().split())
tv_times = [[int(j) for j in input().split()] for i in range(N)]
channells = {}
for i in range(C + 1):
channells[i] = []
max_end = -1
for i in range(N):
s, g, c = tv_times[i]
max_end = max(max_end, g)
channells[c] += [s, g]
tv_times = []
f = [0 for i in range(max_end + 1)]
for cha in channells.keys():
remove_list = []
time = channells[cha]
for i in range(len(time) // 2 - 1):
if time[2 * i + 1] == time[2 * i + 2]:
remove_list.append(time[2 * i + 1])
time = list(set(time) - set(remove_list))
time.sort()
# print(time)
# print(time)
# print(f)
for i in range(len(time) // 2):
f[max(time[2 * i] - 1, 0)] += 1
f[time[2 * i + 1]] -= 1
ans = -1
for i in range(1, max_end):
f[i] += f[i - 1]
if ans < f[i]:
ans = f[i]
# print(f)
print(ans)
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s013727643 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | def ans():
tmp = -9999999999999
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
def calculate(B):
v = []
for n in range(N):
mcnt = 0
for k in range(10):
if B[k] == "1" and F[n][k] == 1:
mcnt += 1
v.append(P[n][mcnt])
return sum(v)
for i in range(1, 1 << 10):
bi = bin(i)
bi = bi[2:]
bi = "0" * (10 - len(bi)) + bi
tmp = max(tmp, calculate(bi))
return print(tmp)
ans()
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s306215747 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | #80
N, A, B = map(int, input().rstrip().split())
print(min(N*A, B) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s245368222 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | n, a, b = [int, input(), split()]
ptint(min(n * a, b))
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s005302993 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | n,a,b = map(int,input()split())
print(min(n*a,b)) | Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
When the minimum fee is x yen, print the value of x.
* * * | s496478323 | Runtime Error | p03501 | Input is given from Standard Input in the following format:
N A B | return min(N * A, B)
| Statement
You are parking at a parking lot. You can choose from the following two fee
plans:
* Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.
* Plan 2: The fee will be B yen, regardless of the duration.
Find the minimum fee when you park for N hours. | [{"input": "7 17 120", "output": "119\n \n\n * If you choose Plan 1, the fee will be 7\u00d717=119 yen.\n * If you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\n* * *"}, {"input": "5 20 100", "output": "100\n \n\nThe fee might be the same in the two plans.\n\n* * *"}, {"input": "6 18 100", "output": "100"}] |
Print the minimum possible number of indices i such that A_i and C_i are
different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
* * * | s631199034 | Accepted | p03151 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N} | n, *l = map(int, open(0).read().split())
d = sorted([a - b for a, b in zip(l[:n], l[n:])]) + [0]
m = [x for x in d if x < 0]
s = sum(m)
c = ~n - 1 if sum(d) < 0 else len(m) - 1
for i in d[::-1]:
s += i
c += 1
if s >= 0:
break
print(c)
| Statement
A university student, Takahashi, has to take N examinations and pass all of
them. Currently, his _readiness_ for the i-th examination is A_{i}, and
according to his investigation, it is known that he needs readiness of at
least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he
has decided to ask a magician, Aoki, to change the readiness for as few
examinations as possible so that he can pass all of them, while not changing
the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and
C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the
following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1. | [{"input": "3\n 2 3 5\n 3 4 1", "output": "3\n \n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is\ndone, he cannot pass the first and second exams. The minimum possible number\nof indices i such that A_i and C_i are different, 3, is achieved when:\n\n * (C_1, C_2, C_3) = (3, 5, 2)\n\n* * *"}, {"input": "3\n 2 3 3\n 2 2 1", "output": "0\n \n\nIn this case, he has to do nothing in order to pass all the exams.\n\n* * *"}, {"input": "3\n 17 7 1\n 25 6 14", "output": "-1\n \n\nIn this case, no matter what is done, he cannot pass all the exams.\n\n* * *"}, {"input": "12\n 757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n 74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212", "output": "5"}] |
Print the minimum possible number of indices i such that A_i and C_i are
different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
* * * | s732493169 | Accepted | p03151 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N} | n, *d = map(int, open(0).read().split())
f = [d[i] - d[n + i] for i in range(n)]
m = [v for v in f if v < 0]
p = sorted(v for v in f if v > 0)
c = len(m)
s = sum(m)
while s < 0 and p:
s += p.pop()
c += 1
print([c, -1][s < 0])
| Statement
A university student, Takahashi, has to take N examinations and pass all of
them. Currently, his _readiness_ for the i-th examination is A_{i}, and
according to his investigation, it is known that he needs readiness of at
least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he
has decided to ask a magician, Aoki, to change the readiness for as few
examinations as possible so that he can pass all of them, while not changing
the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and
C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the
following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1. | [{"input": "3\n 2 3 5\n 3 4 1", "output": "3\n \n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is\ndone, he cannot pass the first and second exams. The minimum possible number\nof indices i such that A_i and C_i are different, 3, is achieved when:\n\n * (C_1, C_2, C_3) = (3, 5, 2)\n\n* * *"}, {"input": "3\n 2 3 3\n 2 2 1", "output": "0\n \n\nIn this case, he has to do nothing in order to pass all the exams.\n\n* * *"}, {"input": "3\n 17 7 1\n 25 6 14", "output": "-1\n \n\nIn this case, no matter what is done, he cannot pass all the exams.\n\n* * *"}, {"input": "12\n 757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n 74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212", "output": "5"}] |
Print the minimum possible number of indices i such that A_i and C_i are
different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
* * * | s969338233 | Runtime Error | p03151 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N} | # coding: utf-8
def main():
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(A) < sum(B):
return -1
diff_sum = 0
diff_cnt = 0
diff_list = [0] * N
for i in range(N):
diff_list[i] = A[i] - B[i]
if A[i] < B[i]:
diff_sum += B[i] - A[i]
diff_cnt += 1
diff_list_sorted = sorted(diff_list, reverse=True)
use_sum = 0
for i in range(N):
if use_sum >= diff_sum:
break
use_sum += diff_list_sorted[i]
diff_cnt += 1
return diff_cnt
if __name__ == "__main__":
print(main()
| Statement
A university student, Takahashi, has to take N examinations and pass all of
them. Currently, his _readiness_ for the i-th examination is A_{i}, and
according to his investigation, it is known that he needs readiness of at
least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he
has decided to ask a magician, Aoki, to change the readiness for as few
examinations as possible so that he can pass all of them, while not changing
the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and
C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the
following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1. | [{"input": "3\n 2 3 5\n 3 4 1", "output": "3\n \n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is\ndone, he cannot pass the first and second exams. The minimum possible number\nof indices i such that A_i and C_i are different, 3, is achieved when:\n\n * (C_1, C_2, C_3) = (3, 5, 2)\n\n* * *"}, {"input": "3\n 2 3 3\n 2 2 1", "output": "0\n \n\nIn this case, he has to do nothing in order to pass all the exams.\n\n* * *"}, {"input": "3\n 17 7 1\n 25 6 14", "output": "-1\n \n\nIn this case, no matter what is done, he cannot pass all the exams.\n\n* * *"}, {"input": "12\n 757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n 74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212", "output": "5"}] |
Print the minimum possible number of indices i such that A_i and C_i are
different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
* * * | s704074429 | Runtime Error | p03151 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N} | n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
surplus = []
short = []
for i in range(n):
if a[i] > b[i]:
surplus.append(a[i]-b[i])
elif b[i] > a[i]:
short.append(b[i]-a[i])
surplus = sorted(surplus)
taken = False
cnt = 0
for i in range(len(short)):
cost = short.pop()
cnt += 1
while cost > 0:
if len(surplus) == 0:
print(-1)
exit()
take = min(cost, surplus[-1])
cost -= take
surplus[-1] -= take
if not taken:
taken = True
cnt += 1
if surplus[-1] == 0:
surplus.pop()
taken = False
print(cnt) | Statement
A university student, Takahashi, has to take N examinations and pass all of
them. Currently, his _readiness_ for the i-th examination is A_{i}, and
according to his investigation, it is known that he needs readiness of at
least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he
has decided to ask a magician, Aoki, to change the readiness for as few
examinations as possible so that he can pass all of them, while not changing
the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and
C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the
following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1. | [{"input": "3\n 2 3 5\n 3 4 1", "output": "3\n \n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is\ndone, he cannot pass the first and second exams. The minimum possible number\nof indices i such that A_i and C_i are different, 3, is achieved when:\n\n * (C_1, C_2, C_3) = (3, 5, 2)\n\n* * *"}, {"input": "3\n 2 3 3\n 2 2 1", "output": "0\n \n\nIn this case, he has to do nothing in order to pass all the exams.\n\n* * *"}, {"input": "3\n 17 7 1\n 25 6 14", "output": "-1\n \n\nIn this case, no matter what is done, he cannot pass all the exams.\n\n* * *"}, {"input": "12\n 757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n 74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212", "output": "5"}] |
Print the minimum possible number of indices i such that A_i and C_i are
different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
* * * | s765064933 | Runtime Error | p03151 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N} | #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912 2の29乗
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N;
ll a[100001],b[100001];
void init(int a[100001]){
for(int i = 0; i < 100001; i++){
a[i] = MM;
}
}
vector<ll> v(0);
ll cnt = 0;
int main(){
cin >> N;
ll sum = 0;
ll sum_up = 0;
for(int i = 0; i < N; i++) cin >> a[i];
for(int i = 0; i < N; i++) cin >> b[i];
for(int i = 0; i < N; i++){
sum += (a[i]-b[i]);
if(a[i] >= b[i]){
sum_up++;
}
if(a[i] < b[i]){
cnt++;
}
}
if(sum < 0 || sum_up < N/2){
cout << -1 << endl;
return 0;
}
cout << cnt << endl;
}
| Statement
A university student, Takahashi, has to take N examinations and pass all of
them. Currently, his _readiness_ for the i-th examination is A_{i}, and
according to his investigation, it is known that he needs readiness of at
least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he
has decided to ask a magician, Aoki, to change the readiness for as few
examinations as possible so that he can pass all of them, while not changing
the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and
C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the
following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1. | [{"input": "3\n 2 3 5\n 3 4 1", "output": "3\n \n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is\ndone, he cannot pass the first and second exams. The minimum possible number\nof indices i such that A_i and C_i are different, 3, is achieved when:\n\n * (C_1, C_2, C_3) = (3, 5, 2)\n\n* * *"}, {"input": "3\n 2 3 3\n 2 2 1", "output": "0\n \n\nIn this case, he has to do nothing in order to pass all the exams.\n\n* * *"}, {"input": "3\n 17 7 1\n 25 6 14", "output": "-1\n \n\nIn this case, no matter what is done, he cannot pass all the exams.\n\n* * *"}, {"input": "12\n 757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n 74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212", "output": "5"}] |
Print the minimum possible number of indices i such that A_i and C_i are
different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
* * * | s355077808 | Runtime Error | p03151 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N} | import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))
b=np.array(list(map(int,input().split())))
c=[]
for i in range(n):
c.append(a[i] - b[i])
c.sort(reverse=True)
d=np.array(c)
z=np.sum(d < 0)
x=np.sum(d[ d < 0])
y=np.sum(d[ d > 0])
if x == 0:
print("0")
exit()
if x + y < 0:
print("-1")
exit()
for i,num in enumerate(c)
x += num
if x >= 0:
print(z+i+1) | Statement
A university student, Takahashi, has to take N examinations and pass all of
them. Currently, his _readiness_ for the i-th examination is A_{i}, and
according to his investigation, it is known that he needs readiness of at
least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he
has decided to ask a magician, Aoki, to change the readiness for as few
examinations as possible so that he can pass all of them, while not changing
the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and
C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the
following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1. | [{"input": "3\n 2 3 5\n 3 4 1", "output": "3\n \n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is\ndone, he cannot pass the first and second exams. The minimum possible number\nof indices i such that A_i and C_i are different, 3, is achieved when:\n\n * (C_1, C_2, C_3) = (3, 5, 2)\n\n* * *"}, {"input": "3\n 2 3 3\n 2 2 1", "output": "0\n \n\nIn this case, he has to do nothing in order to pass all the exams.\n\n* * *"}, {"input": "3\n 17 7 1\n 25 6 14", "output": "-1\n \n\nIn this case, no matter what is done, he cannot pass all the exams.\n\n* * *"}, {"input": "12\n 757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n 74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212", "output": "5"}] |
Print the minimum possible number of indices i such that A_i and C_i are
different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
* * * | s513031872 | Wrong Answer | p03151 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N} | n = int(input())
s = list(map(int, input().split()))
dum = s[0]
count = 0
for i in s:
if i <= dum:
count += 1
dum = min(dum, i)
print(count)
| Statement
A university student, Takahashi, has to take N examinations and pass all of
them. Currently, his _readiness_ for the i-th examination is A_{i}, and
according to his investigation, it is known that he needs readiness of at
least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he
has decided to ask a magician, Aoki, to change the readiness for as few
examinations as possible so that he can pass all of them, while not changing
the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and
C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the
following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1. | [{"input": "3\n 2 3 5\n 3 4 1", "output": "3\n \n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is\ndone, he cannot pass the first and second exams. The minimum possible number\nof indices i such that A_i and C_i are different, 3, is achieved when:\n\n * (C_1, C_2, C_3) = (3, 5, 2)\n\n* * *"}, {"input": "3\n 2 3 3\n 2 2 1", "output": "0\n \n\nIn this case, he has to do nothing in order to pass all the exams.\n\n* * *"}, {"input": "3\n 17 7 1\n 25 6 14", "output": "-1\n \n\nIn this case, no matter what is done, he cannot pass all the exams.\n\n* * *"}, {"input": "12\n 757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n 74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212", "output": "5"}] |
Print the minimum possible number of indices i such that A_i and C_i are
different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
* * * | s221812686 | Accepted | p03151 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N} | # -*- coding: utf-8 -*-
import numpy as np
n = int(input())
tmp = input()
a = [int(k) for k in tmp.split()]
tmp = input()
b = [int(k) for k in tmp.split()]
x = int(0)
a_arr = np.array(a)
b_arr = np.array(b)
c_arr = a_arr - b_arr
c_arr.sort()
if sum(a_arr) < sum(b_arr):
x = -1
elif c_arr[0] >= 0:
x = 0
else:
minus_arr = c_arr[c_arr < 0]
m_ = len(minus_arr)
pls_arr = c_arr[c_arr > 0]
m = sum(minus_arr)
pls = pls_arr.tolist()
pls.sort()
pls.reverse()
i = int(0)
pls_ = int(0)
while i <= -m:
i = i + pls.pop(0)
pls_ = pls_ + 1
x = m_ + pls_
print(x)
| Statement
A university student, Takahashi, has to take N examinations and pass all of
them. Currently, his _readiness_ for the i-th examination is A_{i}, and
according to his investigation, it is known that he needs readiness of at
least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he
has decided to ask a magician, Aoki, to change the readiness for as few
examinations as possible so that he can pass all of them, while not changing
the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and
C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the
following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1. | [{"input": "3\n 2 3 5\n 3 4 1", "output": "3\n \n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is\ndone, he cannot pass the first and second exams. The minimum possible number\nof indices i such that A_i and C_i are different, 3, is achieved when:\n\n * (C_1, C_2, C_3) = (3, 5, 2)\n\n* * *"}, {"input": "3\n 2 3 3\n 2 2 1", "output": "0\n \n\nIn this case, he has to do nothing in order to pass all the exams.\n\n* * *"}, {"input": "3\n 17 7 1\n 25 6 14", "output": "-1\n \n\nIn this case, no matter what is done, he cannot pass all the exams.\n\n* * *"}, {"input": "12\n 757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n 74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212", "output": "5"}] |
Print the minimum possible number of indices i such that A_i and C_i are
different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
* * * | s001539763 | Wrong Answer | p03151 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N} | import numpy as np
| Statement
A university student, Takahashi, has to take N examinations and pass all of
them. Currently, his _readiness_ for the i-th examination is A_{i}, and
according to his investigation, it is known that he needs readiness of at
least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he
has decided to ask a magician, Aoki, to change the readiness for as few
examinations as possible so that he can pass all of them, while not changing
the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and
C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the
following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1. | [{"input": "3\n 2 3 5\n 3 4 1", "output": "3\n \n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is\ndone, he cannot pass the first and second exams. The minimum possible number\nof indices i such that A_i and C_i are different, 3, is achieved when:\n\n * (C_1, C_2, C_3) = (3, 5, 2)\n\n* * *"}, {"input": "3\n 2 3 3\n 2 2 1", "output": "0\n \n\nIn this case, he has to do nothing in order to pass all the exams.\n\n* * *"}, {"input": "3\n 17 7 1\n 25 6 14", "output": "-1\n \n\nIn this case, no matter what is done, he cannot pass all the exams.\n\n* * *"}, {"input": "12\n 757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n 74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212", "output": "5"}] |
Print the minimum possible number of indices i such that A_i and C_i are
different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
* * * | s331321746 | Runtime Error | p03151 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N} | n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = [A[i] - B[i] for i in range(n)]
C.sort()
if sum(C)<0:
print(-1)
exit()
ans = 0
for collections import deque
C = deque(C)
c = 0
while 1:
nc = C.popleft()
if nc >=0:
break
c+= nc
ans += 1
while c<0:
c+=C.popright()
ans += 1
print(ans) | Statement
A university student, Takahashi, has to take N examinations and pass all of
them. Currently, his _readiness_ for the i-th examination is A_{i}, and
according to his investigation, it is known that he needs readiness of at
least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he
has decided to ask a magician, Aoki, to change the readiness for as few
examinations as possible so that he can pass all of them, while not changing
the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and
C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the
following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1. | [{"input": "3\n 2 3 5\n 3 4 1", "output": "3\n \n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is\ndone, he cannot pass the first and second exams. The minimum possible number\nof indices i such that A_i and C_i are different, 3, is achieved when:\n\n * (C_1, C_2, C_3) = (3, 5, 2)\n\n* * *"}, {"input": "3\n 2 3 3\n 2 2 1", "output": "0\n \n\nIn this case, he has to do nothing in order to pass all the exams.\n\n* * *"}, {"input": "3\n 17 7 1\n 25 6 14", "output": "-1\n \n\nIn this case, no matter what is done, he cannot pass all the exams.\n\n* * *"}, {"input": "12\n 757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n 74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212", "output": "5"}] |
Print the minimum possible number of indices i such that A_i and C_i are
different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
* * * | s100183597 | Accepted | p03151 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N} | # 1st: Code Festival 2015 Qualifying B (0408)
if False:
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
A.sort()
B.sort()
ans = "YES"
if N < M:
ans = "NO"
else:
while B:
a = A.pop()
b = B.pop()
if b > a:
ans = "NO"
break
print(ans)
# 2nd: CF2014QA-C
if False:
A, B = map(int, input().split())
def uruu(n):
ret = 0
ret += n // 4
ret -= n // 100
ret += n // 400
return ret
print(uruu(B) - uruu(A - 1))
# 3rd: Code Formula 2014 - C
if False:
S = input()
stack = list(S[::-1])
# print(stack)
user = []
s = stack.pop()
while stack:
# print(s)
if s == "@":
tmp = ""
x = stack.pop()
while not (x in ("@", " ")):
# print(x)
tmp += x
if not stack:
break
x = stack.pop()
user.append(tmp)
s = x
else:
s = stack.pop()
user = list(set(user))
user.sort()
for u in user:
if u:
print(u)
# 4th: Hitachi Programming Contest 2020 - A
if False:
S = input()
hi = ["hi" * i for i in range(1, 10)]
print("Yes" if S in hi else "No")
# 5th: Keyence Programming Contest 2019 - C
if True:
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
S = list(zip(A, B))
if sum(A) < sum(B):
print(-1)
else:
C = []
for s in S:
a, b = s
if a < b:
C.append(s)
CA = sum(C[i][0] for i in range(len(C)))
CB = sum(C[i][1] for i in range(len(C)))
S.sort(key=lambda x: x[0] - x[1])
while CA < CB:
c, d = S.pop()
CA += c
CB += d
C.append((c, d))
print(len(C))
| Statement
A university student, Takahashi, has to take N examinations and pass all of
them. Currently, his _readiness_ for the i-th examination is A_{i}, and
according to his investigation, it is known that he needs readiness of at
least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he
has decided to ask a magician, Aoki, to change the readiness for as few
examinations as possible so that he can pass all of them, while not changing
the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and
C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the
following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1. | [{"input": "3\n 2 3 5\n 3 4 1", "output": "3\n \n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is\ndone, he cannot pass the first and second exams. The minimum possible number\nof indices i such that A_i and C_i are different, 3, is achieved when:\n\n * (C_1, C_2, C_3) = (3, 5, 2)\n\n* * *"}, {"input": "3\n 2 3 3\n 2 2 1", "output": "0\n \n\nIn this case, he has to do nothing in order to pass all the exams.\n\n* * *"}, {"input": "3\n 17 7 1\n 25 6 14", "output": "-1\n \n\nIn this case, no matter what is done, he cannot pass all the exams.\n\n* * *"}, {"input": "12\n 757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n 74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212", "output": "5"}] |
Print the minimum possible number of indices i such that A_i and C_i are
different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
* * * | s775983363 | Wrong Answer | p03151 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N} | def main():
num = int(input())
ability = [int(x) for x in input().split()]
exam = [int(y) for y in input().split()]
sa = sorted(ability)
se = sorted(exam)
for i in range(0, num):
if sa[i] < se[i]:
return -1
a = 0
for x in range(num):
if ability[x] < exam[x]:
a += 1
return a * 2
print(main())
| Statement
A university student, Takahashi, has to take N examinations and pass all of
them. Currently, his _readiness_ for the i-th examination is A_{i}, and
according to his investigation, it is known that he needs readiness of at
least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he
has decided to ask a magician, Aoki, to change the readiness for as few
examinations as possible so that he can pass all of them, while not changing
the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and
C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the
following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1. | [{"input": "3\n 2 3 5\n 3 4 1", "output": "3\n \n\n(A_1, A_2, A_3) = (2, 3, 5) and (B_1, B_2, B_3) = (3, 4, 1). If nothing is\ndone, he cannot pass the first and second exams. The minimum possible number\nof indices i such that A_i and C_i are different, 3, is achieved when:\n\n * (C_1, C_2, C_3) = (3, 5, 2)\n\n* * *"}, {"input": "3\n 2 3 3\n 2 2 1", "output": "0\n \n\nIn this case, he has to do nothing in order to pass all the exams.\n\n* * *"}, {"input": "3\n 17 7 1\n 25 6 14", "output": "-1\n \n\nIn this case, no matter what is done, he cannot pass all the exams.\n\n* * *"}, {"input": "12\n 757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604\n 74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212", "output": "5"}] |
Print coordinates of the tangent points on the circle $c$ based on the
following rules.
* Print the coordinate with smaller $x$ first. In case of a tie, print the coordinate with smaller $y$ first.
The output values should be in a decimal fraction with an error less than
0.00001. | s903502974 | Wrong Answer | p02310 | The input is given in the following format.
$px \; py$
$cx \; cy \; r$
$px$ and $py$ represents the coordinate of the point $p$. $cx$, $cy$ and $r$
represents the center coordinate and radius of the circle $c$ respectively.
All input values are given in integers. | px, py = map(int, input().split())
cx, cy, r = map(int, input().split())
dx, dy = px - cx, py - cy
s2 = dx**2 + dy**2
df = (s2 - r**2) ** 0.5
ix1, ix2 = (dx * r + dy * df) / s2, (dx * r - dy * df) / s2
iy1, iy2 = (dy * r - dx * df) / s2, (dy * r + dx * df) / s2
if (ix1, iy1) > (ix2, iy2):
ix1, ix2 = ix2, ix1
iy1, iy2 = iy2, iy1
print(ix1 + cx, iy1 + cy)
print(ix2 + cx, iy2 + cy)
| Tangent to a Circle
Find the tangent lines between a point $p$ and a circle $c$. | [{"input": "0 0\n 2 2 2", "output": "0.0000000000 2.0000000000\n 2.0000000000 0.0000000000"}, {"input": "-3 0\n 2 2 2", "output": "0.6206896552 3.4482758621\n 2.0000000000 0.0000000000"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s622189016 | Accepted | p03852 | The input is given from Standard Input in the following format:
c | import sys
import math
import collections
import itertools
import array
import inspect
# Set max recursion limit
sys.setrecursionlimit(1000000)
# Debug output
def chkprint(*args):
names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()}
print(", ".join(names.get(id(arg), "???") + " = " + repr(arg) for arg in args))
# Binary converter
def to_bin(x):
return bin(x)[2:]
def li_input():
return [int(_) for _ in input().split()]
def gcd(n, m):
if n % m == 0:
return m
else:
return gcd(m, n % m)
def gcd_list(L):
v = L[0]
for i in range(1, len(L)):
v = gcd(v, L[i])
return v
def lcm(n, m):
return (n * m) // gcd(n, m)
def lcm_list(L):
v = L[0]
for i in range(1, len(L)):
v = lcm(v, L[i])
return v
# Width First Search (+ Distance)
def wfs_d(D, N, K):
"""
D: 隣接行列(距離付き)
N: ノード数
K: 始点ノード
"""
dfk = [-1] * (N + 1)
dfk[K] = 0
cps = [(K, 0)]
r = [False] * (N + 1)
r[K] = True
while len(cps) != 0:
n_cps = []
for cp, cd in cps:
for i, dfcp in enumerate(D[cp]):
if dfcp != -1 and not r[i]:
dfk[i] = cd + dfcp
n_cps.append((i, cd + dfcp))
r[i] = True
cps = n_cps[:]
return dfk
# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
"""
v: 現在のノード
pre: 1つ前のノード
dist: 現在の距離
以下は別途用意する
D: 隣接リスト(行列ではない)
D_dfs_d: dfs_d関数で用いる,始点ノードから見た距離リスト
"""
global D
global D_dfs_d
D_dfs_d[v] = dist
for next_v, d in D[v]:
if next_v != pre:
dfs_d(next_v, v, dist + d)
return
def sigma(N):
ans = 0
for i in range(1, N + 1):
ans += i
return ans
class Combination:
def __init__(self, n, mod):
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, n + 1):
g1.append((g1[-1] * i) % mod)
inverse.append((-inverse[mod % i] * (mod // i)) % mod)
g2.append((g2[-1] * inverse[-1]) % mod)
self.MOD = mod
self.N = n
self.g1 = g1
self.g2 = g2
self.inverse = inverse
def __call__(self, n, r):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return self.g1[n] * self.g2[r] * self.g2[n - r] % self.MOD
# --------------------------------------------
dp = None
def main():
s = input()
if s in "aiueo":
print("vowel")
else:
print("consonant")
main()
| Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s663070157 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | ef rev (s):
_re=''.join(list(reversed(s)))
return _re
name = ['dream','dreamer','eraser','erase']
S = input()
S_re = rev(S)
can = False
can2 = False
for i in range(len(S_re)):
for div in name:
if S_re[i:i+len(div)]==rev(div) :
i+=len(div)
can = True
if can :
can2 = True
break
if not can2 :
break
if can2 :
print('YES')
else :
print('No')
| Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s283777921 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | text = input()
if (text == 'a')
print('vowel')
elif (text == 'i')
print('vowel')
elif (text == 'u')
print('vowel')
elif (text == 'e')
print('vowel')
elif (text == 'o')
print('vowel')
else:
print('consonant') | Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s811404112 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | text = str(input())
if text == a
print(vowel)
elif text == i
print(vowel)
elif text == u
print(vowel)
elif text == e :
print(vowel)
elif text == o ::
print=(vowel)
else:
print=(consonant) | Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s634976152 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | s = input()
if s == 'a' or s == 'i' or s == 'u' or s == 'e' or s == 'o':
ans = 'vowel'
else:
ans = 'consonant"
print(ans) | Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s112139057 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | A=input()
if A="a":
print("vowel")
if A="i":
print("vowel")
if A="u":
print("vowel")
if A="e":
print("vowel")
if A="o":
print("vowel")
else:
print("consonant") | Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s365837591 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | text = input()
if (text == a )
print('vowel')
elif (text == i )
print('vowel')
elif (text == u )
print('vowel')
elif (text == e )
print('vowel')
elif (text == o )
print=('vowel')
else:
print=('consonant') | Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s278129255 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | text = input()
if text == 'a'
print(vowel)
elif text == i
print(vowel)
elif text == u
print(vowel)
elif text == e
print(vowel)
elif text == o
print=(vowel)
else:
print=(consonant) | Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s928360820 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | n = str(input())
if n = "a" or "i" or "u" or "e" or "o":
print("vowe")
else:
print("consonant") | Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s883083997 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | s = input()
if s in ['a', 'i', 'u', 'e'. 'o']:
print('vowel')
else:
print('consonant') | Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s265296137 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | s=input()
print(["vowel","consonant"][s="a" or s="i" or s="u" or s="e" or s="o"])
| Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s868709729 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | a=input()
if a="a" or a="i" or a="u" or a="e" or a="o":
print("vowel")
else:
print("consonant") | Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s879294849 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | c = input()
if c in ['a', 'i', 'u', 'e', 'o']:
print('vowel')
else
print('consonant')
| Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s636273076 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | c = input()
l = ['a'、'e'、'i'、'o'、'u']
print('vowwl' if c in l else 'consonant') | Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s581172615 | Accepted | p03852 | The input is given from Standard Input in the following format:
c | print("vowel" if input().strip() in "aiueo" else "consonant")
| Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s021247060 | Accepted | p03852 | The input is given from Standard Input in the following format:
c | print("vowel" if input() in ["a", "e", "i", "o", "u"] else "consonant")
| Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s117105949 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | x = 'aeiou'
i = input()
if i in x:
print("vowel")
else
print("consonant") | Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s746908021 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | c = input()
if c in "aeiou":
print("vowel")
else:
print("consonant") | Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
If c is a vowel, print `vowel`. Otherwise, print `consonant`.
* * * | s489234322 | Runtime Error | p03852 | The input is given from Standard Input in the following format:
c | C = c
if c == a,e,i,o,u :
print("vowel")
else :
print("consonant") | Statement
Given a lowercase English letter c, determine whether it is a vowel. Here,
there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | [{"input": "a", "output": "vowel\n \n\nSince `a` is a vowel, print `vowel`.\n\n* * *"}, {"input": "z", "output": "consonant\n \n\n* * *"}, {"input": "s", "output": "consonant"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.