description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
n = int(input()) x1, x2 = map(int, input().split()) left = [[0, 0, 0]] * n right = [[0, 0, 0]] * n for i in range(n): k, b = map(int, input().split()) left[i] = [k * x1 + b, k, i] right[i] = [k * x2 + b, -k, i] left.sort() right.sort() ans = "No" for i in range(n): if left[i][2] != right[i][2]: ans = "Yes" print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST LIST NUMBER NUMBER NUMBER VAR ASSIGN VAR BIN_OP LIST LIST NUMBER NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR VAR LIST BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR STRING EXPR FUNC_CALL VAR VAR
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
from sys import stdin def entryPoint(m, c): global x1 return m * x1 + c size, lines = int(input()), [] x1, x2 = map(int, input().split()) for l in stdin.readlines(): m, c = map(int, l.split()) lines.append((entryPoint(m, c), m, c)) lines.sort() for x in range(size - 1): if lines[x][1] != lines[x + 1][1]: intersection = (lines[x + 1][2] - lines[x][2]) / (lines[x][1] - lines[x + 1][1]) if intersection > x1 and intersection < x2: print("YES") exit() print("NO")
FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
n = int(input()) x1, x2 = map(int, input().split(" ")) def intercepts(k, b): y1 = k * x1 + b y2 = k * x2 + b return [y1, y2] inter = [] for i in range(n): k, b = map(int, input().split(" ")) inter += [intercepts(k, b)] inter.sort() right = [] for i in range(n): intercept = inter[i] right += [intercept[1]] right2 = [] for thing in right: right2 += [thing] right.sort() if right == right2: print("NO") else: print("YES")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN LIST VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR LIST FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR LIST VAR NUMBER ASSIGN VAR LIST FOR VAR VAR VAR LIST VAR EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
def check(y1, y2, n): for i in range(n): if y1[i][1] != y2[i][1]: return "YES" return "NO" n = int(input()) eps = 10**-7 x1, x2 = map(int, input().split()) y1 = list() y2 = list() for i in range(n): k, b = map(int, input().split()) f = lambda x: k * x + b y1.append((f(x1 + eps), i)) y2.append((f(x2 - eps), i)) y1.sort() y2.sort() print(check(y1, y2, n))
FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
def main(): n = int(input()) x1, x2 = map(int, input().split()) res = [] for _ in range(n): k, b = map(int, input().split()) res.append((k * x1 + b, k * x2 + b)) res.sort() _, a = res[0] for _, b in res: if a > b: print("YES") return a = b print("NO") main()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
import sys def main(): n = int(input()) x1, x2 = map(int, input().split()) s = [] for _ in range(n): k, b = map(int, sys.stdin.readline().split()) s += [[k * x1 + b, k * x2 + b]] s.sort() for i in range(1, n): if s[i][1] < s[i - 1][1]: print("YES") return print("NO") main()
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST LIST BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING RETURN EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
n = int(input()) done = False a, b = map(int, input().split()) a += 1 / 4000000 b -= 1 / 4000000 lol = [] wow = [] for i in range(n): k, c = map(int, input().split()) lol.append([k * a + c, i]) wow.append([k * b + c, i]) wow.sort() lol.sort() for i in range(n): if lol[i][1] != wow[i][1]: print("YES") done = True break if not done: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
n = int(input()) x1, x2 = map(int, input().split()) res = [0] * n for i in range(n): k, b = map(int, input().split()) res[i] = [k * x1 + b, k * x2 + b] res.sort() for i in range(n): res[i][0], res[i][1] = res[i][1], res[i][0] st = -1 for i in range(n): if i + 1 != n and res[i] == res[i + 1] and st == -1: st = i if st != -1 and res[i] != res[i - 1]: res[st:i].sort() st = -1 for i in range(1, n): if res[i][0] < res[i - 1][0]: print("yes") break else: print("no")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
n = int(input().strip()) x1, x2 = [int(a) for a in input().strip().split()] intersect1 = [] for i in range(n): a, c = [int(a) for a in input().strip().split()] intersect1.append([a * x1 + c, a * x2 + c]) intersect1.sort(key=lambda element: (element[0], element[1])) for i in range(n - 1): if ( intersect1[i][0] < intersect1[i + 1][0] and intersect1[i][1] > intersect1[i + 1][1] ): print("YES") exit() print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
n = int(input()) R = lambda: map(int, input().split()) x1, x2 = R() b = [] V = lambda k, x, b: k * x + b for _ in range(n): ki, bi = R() v1 = V(ki, x1, bi) v2 = V(ki, x2, bi) b.append((v1, v2)) b = sorted(b) for i in range(n - 1): if b[i + 1][1] < b[i][1]: print("YES") exit() print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
import sys n = int(sys.stdin.readline()) x1, x2 = map(int, sys.stdin.readline().split()) a = [] k = [0] * n for i in range(n): k[i] = list(map(int, sys.stdin.readline().split())) y1 = k[i][0] * x1 + k[i][1] y2 = k[i][0] * x2 + k[i][1] a.append((y1, y2)) a.sort() f = False x = a[0][1] for y1, y2 in a: if y2 < x: f = True else: x = max(x, y2) if f: print("YES") else: print("NO")
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
def getSegment(line, x1, x2): x1 += 1e-09 x2 -= 1e-09 k, b = line P1 = x1, k * x1 + b P2 = x2, k * x2 + b return P1, P2 def doesIntersect(segment1, segment2): P11, P12 = segment1 P21, P22 = segment2 return (P11 < P21) != (P12 < P22) n = int(input()) data = [] x1, x2 = list(map(int, input().split())) for i in range(n): k, b = list(map(int, input().split())) data.append((k, b)) segments = [getSegment(line, x1, x2) for line in data] segments.sort() check_intersections = map(doesIntersect, segments, segments[1:]) if 1 in check_intersections: print("YES") else: print("NO")
FUNC_DEF VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR RETURN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
n = int(input()) x1, x2 = [int(i) for i in input().split()] funcs = [] m = 0 L = [] R = [] for i in range(n): k = input() b = int(k.split()[1]) k = int(k.split()[0]) L.append((k * x1 + b, k, i)) R.append((k * x2 + b, -k, i)) L.sort() R.sort() L = [i[2] for i in L] R = [i[2] for i in R] print(["YES", "NO"][L == R])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR LIST STRING STRING VAR VAR
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
ada = False n = input() apapun = input().split() x1 = int(apapun[0]) x2 = int(apapun[1]) y = [] for i in range(int(n)): whatevs = "" whatevs = input().split() y.append( [int(whatevs[0]) * x1 + int(whatevs[1]), int(whatevs[0]) * x2 + int(whatevs[1])] ) y = sorted(y, key=lambda x: (x[0], x[1])) for i in range(1, len(y)): if y[i][1] < y[i - 1][1]: ada = True break if ada: print("YES") else: print("NO")
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
n = int(input()) x1, x2 = [float(x) for x in input().split()] delta = 1e-07 y1 = list() y2 = list() new_x1 = x1 + delta new_x2 = x2 - delta for i in range(n): k, b = [int(x) for x in input().split()] y1.append((i, k * new_x1 + b)) y2.append((i, k * new_x2 + b)) y1.sort(key=lambda x: x[1]) y2.sort(key=lambda x: x[1]) has_intersection = False for i in range(n): if y1[i][0] is not y2[i][0]: has_intersection = True if has_intersection: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
n = int(input()) x1, x2 = map(int, input().split()) ps = [map(int, input().split()) for _ in range(n)] ys = [0] * n for i, (k, b) in enumerate(ps): ys[i] = k * x1 + b, k * x2 + b ys.sort() max_y = -float("inf") ok = False for y1, y2 in ys: if y2 < max_y: ok = True break max_y = max(max_y, y2) print("YES" if ok else "NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
n = int(input()) x1, x2 = [int(x) for x in input().split(" ")] YSSorted = [] for i in range(n): k, b = [int(x) for x in input().split(" ")] y1 = k * x1 + b y2 = k * x2 + b YSSorted.append((y1, y2)) YSSorted.sort(reverse=True) def solve(YSSorted): minY2 = YSSorted[0][1] for y1, y2 in YSSorted: if y2 > minY2: return "Yes" minY2 = min(minY2, y2) return "No" print(solve(YSSorted))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR VAR IF VAR VAR RETURN STRING ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
n = int(input()) x1, x2 = map(int, input().split()) points = [list(map(int, input().split())) for _ in range(n)] one = list() two = list() for i in range(n): k, b = points[i] one.append((k * (x1 + 1e-10) + b, i)) two.append((k * (x2 - 1e-10) + b, i)) one.sort() two.sort() overlap = False for i in range(n): if one[i][1] != two[i][1]: overlap = True break if overlap: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
N = int(input()) x1, x2 = list(map(int, input().split())) x = [] y = [] for i in range(0, N): m, c = list(map(int, input().split())) x.append((m * (x1 + 1e-10) + c, i)) y.append((m * (x2 - 1e-10) + c, i)) x.sort() y.sort() a = [] b = [] for i in range(N): a.append(x[i][1]) b.append(y[i][1]) if a == b: print("NO") else: print("YES")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
import sys n = int(input()) k = [] b = [] x1, x2 = (int(i) for i in input().split()) for i in range(n): k1, b1 = (int(j) for j in input().split()) k.append(k1) b.append(b1) zn = [(k[i] * x1 + b[i], k[i] * x2 + b[i]) for i in range(n)] zn.sort() found = False for i in range(n - 1): if zn[i][1] > zn[i + 1][1]: found = True break if found: print("YES") else: print("NO")
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
def main(): N = int(input()) X1, X2 = [int(i) for i in input().split()] X1 += 1e-08 X2 -= 1e-08 retas = [] for n in range(N): retas.append([int(i) for i in input().split()]) B1 = {} B2 = {} for n in range(N): k = retas[n][0] b = retas[n][1] B1[k * X1 + b] = n B2[k * X2 + b] = n L1 = list(B1.keys()) L2 = list(B2.keys()) L1.sort() L2.sort() flag = True for n in range(N): if B1[L1[n]] != B2[L2[n]]: flag = False break if not flag: print("YES") else: print("NO") main()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
n = int(input()) x1, x2 = map(int, input().split()) mass = [] for i in range(n): k, b = map(int, input().split()) mass.append((k, b)) tmp_mass = [0] * len(mass) for i in range(len(mass)): tmp_mass[i] = mass[i][1] + mass[i][0] * x1, mass[i][1] + mass[i][0] * x2 tmp_mass.sort(key=lambda x: (x[0], x[1])) flag = False for i in range(n - 1): if tmp_mass[i][1] > tmp_mass[i + 1][1] and tmp_mass[i + 1][0] != tmp_mass[i][0]: flag = True break if flag: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine whether there is at least one point of intersection of two of these lines, that lays strictly inside the strip between x_1 < x_2. In other words, is it true that there are 1 ≤ i < j ≤ n and x', y', such that: y' = k_{i} * x' + b_{i}, that is, point (x', y') belongs to the line number i; y' = k_{j} * x' + b_{j}, that is, point (x', y') belongs to the line number j; x_1 < x' < x_2, that is, point (x', y') lies inside the strip bounded by x_1 < x_2. You can't leave Anton in trouble, can you? Write a program that solves the given task. -----Input----- The first line of the input contains an integer n (2 ≤ n ≤ 100 000) — the number of lines in the task given to Anton. The second line contains integers x_1 and x_2 ( - 1 000 000 ≤ x_1 < x_2 ≤ 1 000 000) defining the strip inside which you need to find a point of intersection of at least two lines. The following n lines contain integers k_{i}, b_{i} ( - 1 000 000 ≤ k_{i}, b_{i} ≤ 1 000 000) — the descriptions of the lines. It is guaranteed that all lines are pairwise distinct, that is, for any two i ≠ j it is true that either k_{i} ≠ k_{j}, or b_{i} ≠ b_{j}. -----Output----- Print "Yes" (without quotes), if there is at least one intersection of two distinct lines, located strictly inside the strip. Otherwise print "No" (without quotes). -----Examples----- Input 4 1 2 1 2 1 0 0 1 0 2 Output NO Input 2 1 3 1 0 -1 3 Output YES Input 2 1 3 1 0 0 2 Output YES Input 2 1 3 1 0 0 3 Output NO -----Note----- In the first sample there are intersections located on the border of the strip, but there are no intersections located strictly inside it. [Image]
import sys input = sys.stdin.readline n = int(input()) x1, x2 = map(int, input().split()) s = [] for _ in range(n): k, b = map(int, input().split()) s.append([x1 * k + b, x2 * k + b]) s.sort() ans = "NO" for i in range(1, n): x1, x2 = s[i - 1] x3, x4 = s[i] if x1 < x3 and x2 > x4 or x1 > x3 and x2 < x4: ans = "YES" break print(ans)
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR STRING EXPR FUNC_CALL VAR VAR
Write a program to find the n-th ugly number. Ugly numbers are positive integers which are divisible by a or b or c.   Example 1: Input: n = 3, a = 2, b = 3, c = 5 Output: 4 Explanation: The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3rd is 4. Example 2: Input: n = 4, a = 2, b = 3, c = 4 Output: 6 Explanation: The ugly numbers are 2, 3, 4, 6, 8, 9, 10, 12... The 4th is 6. Example 3: Input: n = 5, a = 2, b = 11, c = 13 Output: 10 Explanation: The ugly numbers are 2, 4, 6, 8, 10, 11, 12, 13... The 5th is 10. Example 4: Input: n = 1000000000, a = 2, b = 217983653, c = 336916467 Output: 1999999984   Constraints: 1 <= n, a, b, c <= 10^9 1 <= a * b * c <= 10^18 It's guaranteed that the result will be in range [1, 2 * 10^9]
class Solution: def nthUglyNumber(self, n: int, a: int, b: int, c: int) -> int: ab = a * b // math.gcd(a, b) bc = b * c // math.gcd(c, b) ac = a * c // math.gcd(a, c) abc = ab * c // math.gcd(ab, c) def nthUgly(k: int) -> bool: h = k // a + k // b + k // c - k // ab - k // ac - k // bc + k // abc if h >= n: return True return False left, right = 1, 10**10 while left < right: mid = (right + left) // 2 if nthUgly(mid): right = mid else: left = mid + 1 return left
CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER VAR ASSIGN VAR VAR NUMBER BIN_OP NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR
Write a program to find the n-th ugly number. Ugly numbers are positive integers which are divisible by a or b or c.   Example 1: Input: n = 3, a = 2, b = 3, c = 5 Output: 4 Explanation: The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3rd is 4. Example 2: Input: n = 4, a = 2, b = 3, c = 4 Output: 6 Explanation: The ugly numbers are 2, 3, 4, 6, 8, 9, 10, 12... The 4th is 6. Example 3: Input: n = 5, a = 2, b = 11, c = 13 Output: 10 Explanation: The ugly numbers are 2, 4, 6, 8, 10, 11, 12, 13... The 5th is 10. Example 4: Input: n = 1000000000, a = 2, b = 217983653, c = 336916467 Output: 1999999984   Constraints: 1 <= n, a, b, c <= 10^9 1 <= a * b * c <= 10^18 It's guaranteed that the result will be in range [1, 2 * 10^9]
class Solution: def nthUglyNumber(self, n: int, a: int, b: int, c: int) -> int: ab = a * b // math.gcd(a, b) bc = b * c // math.gcd(b, c) ca = a * c // math.gcd(c, a) abc = ab * c // math.gcd(ab, c) lo = 1 hi = 2 * 10**9 while lo < hi: m = (lo + hi) // 2 cnt = m // a + m // b + m // c - m // ab - m // bc - m // ca + m // abc if cnt < n: lo = m + 1 else: hi = m return lo
CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR VAR
Write a program to find the n-th ugly number. Ugly numbers are positive integers which are divisible by a or b or c.   Example 1: Input: n = 3, a = 2, b = 3, c = 5 Output: 4 Explanation: The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3rd is 4. Example 2: Input: n = 4, a = 2, b = 3, c = 4 Output: 6 Explanation: The ugly numbers are 2, 3, 4, 6, 8, 9, 10, 12... The 4th is 6. Example 3: Input: n = 5, a = 2, b = 11, c = 13 Output: 10 Explanation: The ugly numbers are 2, 4, 6, 8, 10, 11, 12, 13... The 5th is 10. Example 4: Input: n = 1000000000, a = 2, b = 217983653, c = 336916467 Output: 1999999984   Constraints: 1 <= n, a, b, c <= 10^9 1 <= a * b * c <= 10^18 It's guaranteed that the result will be in range [1, 2 * 10^9]
class Solution: def nthUglyNumber(self, n: int, a: int, b: int, c: int) -> int: def enough(num): total = ( num // a + num // b + num // c - num // ab - num // bc - num // ac + num // abc ) return total >= n ab = a * b // math.gcd(a, b) ac = a * c // math.gcd(a, c) bc = b * c // math.gcd(b, c) abc = a * bc // math.gcd(a, bc) left, right = 1, min(a, b, c) * n while left < right: mid = left + (right - left) // 2 if enough(mid): right = mid else: left = mid + 1 return left
CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR
Write a program to find the n-th ugly number. Ugly numbers are positive integers which are divisible by a or b or c.   Example 1: Input: n = 3, a = 2, b = 3, c = 5 Output: 4 Explanation: The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3rd is 4. Example 2: Input: n = 4, a = 2, b = 3, c = 4 Output: 6 Explanation: The ugly numbers are 2, 3, 4, 6, 8, 9, 10, 12... The 4th is 6. Example 3: Input: n = 5, a = 2, b = 11, c = 13 Output: 10 Explanation: The ugly numbers are 2, 4, 6, 8, 10, 11, 12, 13... The 5th is 10. Example 4: Input: n = 1000000000, a = 2, b = 217983653, c = 336916467 Output: 1999999984   Constraints: 1 <= n, a, b, c <= 10^9 1 <= a * b * c <= 10^18 It's guaranteed that the result will be in range [1, 2 * 10^9]
class Solution: def nthUglyNumber(self, n: int, a: int, b: int, c: int) -> int: def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return a * b // gcd(a, b) def count_ugly(N, a, b, c): ab, ac, bc = lcm(a, b), lcm(a, c), lcm(b, c) abc = lcm(ab, c) return N // a + N // b + N // c - N // ab - N // ac - N // bc + N // abc s, e = 1, 2 * 10**9 while s <= e: m = s + (e - s) // 2 cnt = count_ugly(m, a, b, c) if cnt >= n: e = m - 1 else: s = m + 1 return s
CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF WHILE VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER BIN_OP NUMBER BIN_OP NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR
Write a program to find the n-th ugly number. Ugly numbers are positive integers which are divisible by a or b or c.   Example 1: Input: n = 3, a = 2, b = 3, c = 5 Output: 4 Explanation: The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3rd is 4. Example 2: Input: n = 4, a = 2, b = 3, c = 4 Output: 6 Explanation: The ugly numbers are 2, 3, 4, 6, 8, 9, 10, 12... The 4th is 6. Example 3: Input: n = 5, a = 2, b = 11, c = 13 Output: 10 Explanation: The ugly numbers are 2, 4, 6, 8, 10, 11, 12, 13... The 5th is 10. Example 4: Input: n = 1000000000, a = 2, b = 217983653, c = 336916467 Output: 1999999984   Constraints: 1 <= n, a, b, c <= 10^9 1 <= a * b * c <= 10^18 It's guaranteed that the result will be in range [1, 2 * 10^9]
class Solution: def nthUglyNumber(self, n: int, a: int, b: int, c: int) -> int: def lcm(a, b): return a * b // math.gcd(a, b) nums = sorted([a, b, c]) nums2 = [lcm(a, b), lcm(b, c), lcm(a, c)] nums3 = lcm(nums2[0], c) lo, hi = n, nums[-1] * n while lo < hi: mid = (lo + hi) // 2 rank = ( sum(mid // n for n in nums) - sum(mid // n for n in nums2) + mid // nums3 ) if rank < n: lo = mid + 1 else: hi = mid return lo
CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR LIST FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
import sys A, B, C, D = [int(i) for i in sys.stdin.read().split()] if A * D - B * C == 0: print(0) else: k1 = abs(A + D + B + C) k2 = abs(A + D - B - C) k3 = abs(A - D + B - C) k4 = abs(A - D - B + C) print(abs(A * D - B * C) / max(k1, k2, k3, k4))
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR VAR VAR VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
a, b = list(map(int, input().split())) c, d = list(map(int, input().split())) z = a * d - b * c if z == 0: print(0) return t = max(abs(a + b + c + d), abs(a - b - c + d), abs(a - b + c - d), abs(a + b - c - d)) print(abs(z / t))
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
import sys A, B, C, D = [int(i) for i in sys.stdin.read().split()] if A * D - B * C == 0: result = 0 else: result = float("inf") for sa in [-1, 1]: for sb in [-1, 1]: for sc in [-1, 1]: for sd in [-1, 1]: coefA = sa * sd - sb * sc coefB = sa * D + sd * A - sb * C - sc * B coefC = A * D - B * C if coefA == 0 and coefB != 0: v = -coefC / coefB result = min(result, abs(v)) print(result)
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR LIST NUMBER NUMBER FOR VAR LIST NUMBER NUMBER FOR VAR LIST NUMBER NUMBER FOR VAR LIST NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
a, b = [int(x) for x in input().split()] c, d = [int(x) for x in input().split()] def isCrossing(square1, square2): for vert in square1: if vert[0] == 0 or vert[1] == 0: return True if square2[0][1] <= vert[1] * square2[0][0] / vert[0] <= square2[1][1]: return True if square2[0][0] <= vert[0] * square2[0][1] / vert[1] <= square2[3][0]: return True if square2[3][1] <= vert[1] * square2[2][0] / vert[0] <= square2[2][1]: return True if square2[1][0] <= vert[0] * square2[1][1] / vert[1] <= square2[2][0]: return True for vert in square2: if vert[0] == 0 or vert[1] == 0: return True if square1[0][1] <= vert[1] * square1[0][0] / vert[0] <= square1[1][1]: return True if square1[0][0] <= vert[0] * square1[0][1] / vert[1] <= square1[3][0]: return True if square1[3][1] <= vert[1] * square1[2][0] / vert[0] <= square1[2][1]: return True if square1[1][0] <= vert[0] * square1[1][1] / vert[1] <= square1[2][0]: return True return False def binSearch(left, right, a, b, c, d): m = (left + right) / 2 eps = 10**-10 while abs(m - left) > eps and abs(right - m) > eps: if isCrossing( ([a - m, b - m], [a - m, b + m], [a + m, b + m], [a + m, b - m]), ([c - m, d - m], [c - m, d + m], [c + m, d + m], [c + m, d - m]), ): right = m else: left = m m = (left + right) / 2 return m print(binSearch(10**-10, 2 * 10**9, a, b, c, d))
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR VAR IF VAR NUMBER NUMBER VAR NUMBER NUMBER RETURN NUMBER IF VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER NUMBER RETURN NUMBER IF VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER NUMBER RETURN NUMBER IF VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER NUMBER RETURN NUMBER IF VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER NUMBER RETURN NUMBER FOR VAR VAR IF VAR NUMBER NUMBER VAR NUMBER NUMBER RETURN NUMBER IF VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER NUMBER RETURN NUMBER IF VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER NUMBER RETURN NUMBER IF VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER NUMBER RETURN NUMBER IF VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR IF FUNC_CALL VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER BIN_OP NUMBER BIN_OP NUMBER NUMBER VAR VAR VAR VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
a, b = map(int, input().split()) c, d = map(int, input().split()) l = 0 r = 10**10 if a * d == b * c: print(0) else: for i in range(10000): x = (l + r) / 2 a1 = (a - x) * (d - x) a2 = (a + x) * (d + x) a3 = (a + x) * (d - x) a4 = (a - x) * (d + x) b1 = (b - x) * (c - x) b2 = (b + x) * (c + x) b3 = (b + x) * (c - x) b4 = (b - x) * (c + x) mna = min(a1, a2, a3, a4) mxa = max(a1, a2, a3, a4) mnb = min(b1, b2, b3, b4) mxb = max(b1, b2, b3, b4) if mxa >= mnb and mxb >= mna: r = x else: l = x print("%0.10f" % x)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER IF BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
a, b = map(int, input().split()) c, d = map(int, input().split()) mn = min(a * d, b * c) mx = max(a * d, b * c) x = 10**18 if a + b + c + d != 0: x = abs((b * c - a * d) / (a + b + c + d)) if a + b - c - d != 0: x = min(abs((b * c - a * d) / (a + b - c - d)), x) if a - b + c - d != 0: x = min(abs((b * c - a * d) / (a - b + c - d)), x) if a - b - c + d != 0: x = min(abs((b * c - a * d) / (a - b - c + d)), x) if a + b + c + d == 0: x = 0 print(x)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
a, b = map(int, input().split()) c, d = map(int, input().split()) if a * d - b * c == 0: print(0) else: curpos = a * d - b * c >= 0 small = 0 large = 1e18 for iteration in range(200): avg = (small + large) / 2 works = False for ach in range(-1, 2, 2): for bch in range(-1, 2, 2): for cch in range(-1, 2, 2): for dch in range(-1, 2, 2): newpos = (a + ach * avg) * (d + dch * avg) - (b + bch * avg) * ( c + cch * avg ) >= 0 if newpos != curpos: works = True if works: large = avg else: small = avg print(small)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
import itertools def minimize(m): ad = [m[0][0] * m[3][0], m[0][0] * m[3][1] + m[0][1] * m[3][0], m[0][1] * m[3][1]] bc = [m[1][0] * m[2][0], m[1][0] * m[2][1] + m[1][1] * m[2][0], m[1][1] * m[2][1]] det = [ad[0] - bc[0], ad[1] - bc[1], ad[2] - bc[2]] if det[0] != 0: disc = det[1] ** 2 - 4 * det[0] * det[2] if disc < 0: return [] return [ (-det[1] + disc**0.5) / (2 * det[0]), (-det[1] - disc**0.5) / (2 * det[0]), ] if det[1] != 0: return [-det[2] / det[1]] if det[2] != 0: return [] return [0] def main(): matrix = read() + read() import itertools r = range(4) ans = 10**18 for i in range(5): for k in itertools.combinations(r, i): m = [(1 if j in k else -1, matrix[j]) for j in range(4)] for res in minimize(m): if abs(res) < ans: ans = abs(res) print(ans) def read(mode=2): inputs = input().strip() if mode == 0: return inputs if mode == 1: return inputs.split() if mode == 2: return list(map(int, inputs.split())) def write(s="\n"): if s is None: s = "" if isinstance(s, list): s = " ".join(map(str, s)) s = str(s) print(s, end="") write(main())
IMPORT FUNC_DEF ASSIGN VAR LIST BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR LIST BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR LIST BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN LIST RETURN LIST BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER VAR NUMBER IF VAR NUMBER NUMBER RETURN LIST BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER NUMBER RETURN LIST RETURN LIST NUMBER FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR IMPORT ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN FUNC_CALL VAR IF VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_DEF STRING IF VAR NONE ASSIGN VAR STRING IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
def work(A, B, C, D): tmp0 = A * D - B * C tmp1 = a * D + d * A - b * C - c * B tmp2 = a * d - b * c if tmp0 == 0: if tmp1 == 0 and tmp2 == 0: return 0 elif tmp1 != 0: return abs(tmp2 / tmp1) else: delta = tmp1 * tmp1 - tmp0 * tmp2 * 4 if delta >= 0: return abs((tmp1 + delta**0.5) / (tmp0 * 2)) return 1e18 a, b = map(int, input().strip().split()) c, d = map(int, input().strip().split()) ans = 1e18 ans = min(ans, work(1, 1, 1, 1)) ans = min(ans, work(1, 1, 1, -1)) ans = min(ans, work(1, 1, -1, 1)) ans = min(ans, work(1, 1, -1, -1)) ans = min(ans, work(1, -1, 1, 1)) ans = min(ans, work(1, -1, 1, -1)) ans = min(ans, work(1, -1, -1, 1)) ans = min(ans, work(1, -1, -1, -1)) ans = min(ans, work(-1, 1, 1, 1)) ans = min(ans, work(-1, 1, 1, -1)) ans = min(ans, work(-1, 1, -1, 1)) ans = min(ans, work(-1, 1, -1, -1)) ans = min(ans, work(-1, -1, 1, 1)) ans = min(ans, work(-1, -1, 1, -1)) ans = min(ans, work(-1, -1, -1, 1)) ans = min(ans, work(-1, -1, -1, -1)) print("%.10f" % ans)
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
m = list(map(int, input().split() + input().split())) def f(r): a = (m[0] + r) * (m[3] + r) b = (m[0] + r) * (m[3] - r) c = (m[0] - r) * (m[3] + r) d = (m[0] - r) * (m[3] - r) x1 = min(a, b, c, d) x2 = max(a, b, c, d) a = (m[1] + r) * (m[2] + r) b = (m[1] + r) * (m[2] - r) c = (m[1] - r) * (m[2] + r) d = (m[1] - r) * (m[2] - r) y1 = min(a, b, c, d) y2 = max(a, b, c, d) if y1 > x2 or x1 > y2: return False return True l = 0 r = 10**20 for i in range(10000): mid = (l + r) / 2 if f(mid): r = mid else: l = mid print(l)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
a, b = map(int, input().split()) c, d = map(int, input().split()) if a == b == c == d == 0: print(0) else: x = max( abs(a + b + c + d), abs(a + b - c - d), abs(a - b + c - d), abs(a - b - c + d) ) print(abs((a * d - b * c) / x))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
import sys A, B, C, D = map(int, sys.stdin.read().split()) k = max(map(abs, [A + B + C + D, A + B - C - D, A - B + C - D, A - B - C + D])) + 1e-09 print((0, abs(A * D - B * C) / k)[bool(k)])
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR LIST BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
__author__ = "Данила" a, b = list(map(int, input().split())) c, d = list(map(int, input().split())) def solve(x, y, z): if y**2 - 4 * z * x < 0: return -(10**27) else: disi = y**2 - 4 * z * x return min(abs((-y + disi**0.5) / 2 * x), abs((-y - disi**0.5) / 2 * x)) if a * d - b * c == 0: print(0) else: det = a * d - b * c k = max( a + d + b + c, a - d + c - b, a - d - c + b, a + d - b - c, -a + d - b + c, -a + d - c + b, -a - d + b + c, -a - b - c - d, ) a1 = abs(det / k) ans = a1 print(ans)
ASSIGN VAR STRING ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR VAR NUMBER RETURN BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
def calc_range(x, y, d): l1 = x - d r1 = x + d l2 = y - d r2 = y + d points = sorted([l1 * l2, l1 * r2, r1 * l2, r1 * r2]) return points[0], points[3] def main(): a, b = map(int, input().split()) c, d = map(int, input().split()) l = 0.0 r = 10000000000.0 for iter in range(100): m = (l + r) / 2.0 minA, maxA = calc_range(a, d, m) minB, maxB = calc_range(b, c, m) if maxA < minB or maxB < minA: l = m else: r = m print(r) main()
FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
def seg(x, y, h): A = [x - h, x + h] B = [y - h, y + h] Z = [] for a in A: for b in B: Z.append(a * b) Z.sort() return Z[0], Z[-1] def check(a, b, c, d, h): x1, y1 = seg(a, d, h) x2, y2 = seg(b, c, h) return max(x1, x2) <= min(y1, y2) a, b = map(int, input().split()) c, d = map(int, input().split()) l = 0 r = max(abs(a), abs(b), abs(c), abs(d)) for i in range(100): m = (l + r) / 2 if check(a, b, c, d, m): r = m else: l = m print((r + l) / 2)
FUNC_DEF ASSIGN VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR RETURN VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
from sys import * a, b, c, d = map(int, stdin.read().split()) print(abs(a * d - b * c) / max(abs(a + b) + abs(c + d), abs(a - b) + abs(c - d), 1e-09))
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
a = abs A, B, C, D = map(int, (input() + " " + input()).split()) print(a(A * D - B * C) / max(a(A + B) + a(C + D) + 1e-09, a(A - B) + a(C - D)))
ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
store1 = input("").split(" ") a = int(store1[0]) b = int(store1[1]) store2 = input("").split(" ") c = int(store2[0]) d = int(store2[1]) lo = 0 hi = 2 * 10**18 while hi - lo > 10**-10 * lo: mid = (hi + lo) / 2.0 mini = 2 * 10**19 maxi = -2 * 10**19 for t in range(1 << 4): store = [a, b, d, c] for k in range(4): if 1 << k & t != 0: store[k] += mid else: store[k] -= mid x = store[0] * store[2] - store[1] * store[3] if x >= maxi: maxi = x if x <= mini: mini = x if mini <= maxi and maxi >= 0 and mini <= 0: hi = mid else: lo = mid print(lo)
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER WHILE BIN_OP VAR VAR BIN_OP BIN_OP NUMBER NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR NUMBER VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$ A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix $A = \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right)$. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||. -----Input----- The first line contains two integers a and b (|a|, |b| ≤ 10^9), the elements of the first row of matrix A. The second line contains two integers c and d (|c|, |d| ≤ 10^9) the elements of the second row of matrix A. -----Output----- Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10^{ - 9}. -----Examples----- Input 1 2 3 4 Output 0.2000000000 Input 1 0 0 1 Output 0.5000000000 -----Note----- In the first sample matrix B is $\left(\begin{array}{ll}{1.2} & {1.8} \\{2.8} & {4.2} \end{array} \right)$ In the second sample matrix B is $\left(\begin{array}{ll}{0.5} & {0.5} \\{0.5} & {0.5} \end{array} \right)$
EPS = 1e-11 INF = float("inf") def multiply(a, b): m = INF M = -INF for i in range(2): for j in range(2): m = min(m, a[i] * b[j]) M = max(M, a[i] * b[j]) return m, M def intersect(a, b): return a[0] <= b[1] and b[0] <= a[1] a, b = map(float, input().split()) c, d = map(float, input().split()) lo = 0 hi = 1000000000.0 nIters = 0 while nIters < 1000 and abs(lo - hi) > EPS: mi = (lo + hi) / 2 i1 = multiply((a - mi, a + mi), (d - mi, d + mi)) i2 = multiply((b - mi, b + mi), (c - mi, c + mi)) if intersect(i1, i2): hi = mi else: lo = mi nIters += 1 print("{:.10f}".format(hi))
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF RETURN VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) a = list(map(int, input().split())) a.sort() if a[n] / a[0] >= 2: x = a[0] else: x = a[n] / 2 sum = 3 * n * x print(min(sum, w))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF BIN_OP VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) ls = list(map(int, input().split())) ls.sort() mi = min(ls[0], ls[n] / 2) print(min(w, 3 * mi * n))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) G = a[-1] B = a[n - 1] if B >= 2 * G: print(min(w, 3 * G * n)) else: G = B / 2 print(min(w, 3 * G * n))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) cups = [int(cup) for cup in input().split()] cups.sort() girl_cup = cups[0] boy_cup = -1 for i in range(1, n + 1): boy_cup = cups[i] if boy_cup >= girl_cup * 2: break if boy_cup < girl_cup * 2: result = (boy_cup + boy_cup / 2) * n elif boy_cup > girl_cup * 2: result = (girl_cup * 2 + girl_cup) * n else: result = (boy_cup + girl_cup) * n if result <= int(result): result = int(result) if result > w: result = w print(result)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
def inp(): return map(int, input().split(" ")) n, w = inp() v = inp() v = sorted(v) if v[n] * 1.0 / v[0] >= 2.0: x = v[0] else: x = v[n] * 1.0 / 2.0 sum = 3.0 * n * x if sum > w: sum = w print(sum)
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) a = list(map(int, input().split())) a.sort() res = 0 posi = a[n] / a[0] if posi >= 2: x = a[0] res = n * x * 2 + n * x else: x = a[n] res = n * x + n * x / 2 if res > w: res = w print(res)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) a = list(map(int, input().split())) a.sort() girl = a[:n] boy = a[n:] minG = min(girl) minB = min(boy) x = min(minG, minB / 2, w / (3 * n)) ans = 3 * x * n if ans - int(ans) == 0: print(int(ans)) else: print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR IF BIN_OP VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
def main(): n, w = map(int, input().split()) a = list(sorted(map(int, input().split()))) q = min(min(a[:n]), min(a[n:]) / 2) print(min(q * 3 * n, w)) main()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split(" ")) c = input().split(" ") c = [int(i) for i in c] c.sort() k = min(c[0], c[n] / 2) * 3 * n print(min(k, w))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = (int(i) for i in input().split()) a = [int(i) for i in input().split()] a.sort() if 2 * a[0] <= a[n]: print(min(w, 3 * a[0] * n)) else: print(min(w, 1.5 * a[n] * n))
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF BIN_OP NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = [int(i) for i in input().split()] a = [int(i) for i in input().split()] c = w / 3 / n a.sort() if a[0] > c and a[n] > 2 * c: print(w) else: print(min(a[n] / 2, a[0]) * 3 * n)
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR IF VAR NUMBER VAR VAR VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR NUMBER NUMBER VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
def sinput(): s = input().split() return int(s[0]), int(s[1]) n, w = sinput() s = input().split() s = [int(i) for i in s] s.sort() print(min(s[0] * 3 * n, s[n] * 3 / 2 * n, w))
FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR RETURN FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
import sys n, w = [int(i) for i in sys.stdin.readline().split()] teacups = sorted([int(i) for i in sys.stdin.readline().split()]) girl, boy = [teacups[0], teacups[n]] boy_ml = min(girl * 2, boy) girl_ml = boy_ml / 2 total = min(n * (boy_ml + girl_ml), w) print(total)
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
def main(): n, w = list(map(int, input().split())) a = sorted(map(int, input().split())) print(min(w, min(a[0], a[n] * 0.5) * 3 * n)) def __starting_point(): main() __starting_point()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER VAR FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) a = list(map(int, input().split())) can_pour_g = w / (3 * n) a = sorted(a)[::-1] b = a[:n] g = a[n:] mb = min(b) mg = min(g) pg = 0 if mb > mg * 2: pg = mg else: pg = mb / 2 if can_pour_g < pg: print(n * can_pour_g + 2 * n * can_pour_g) else: print(n * pg + 2 * n * pg)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) a = list(map(int, input().split())) a = sorted(a) result = 0 i = a[0] max_of_size_cup = a[n] if float(max_of_size_cup) / 2 <= i: result = max_of_size_cup * n + float(max_of_size_cup) / 2 * n else: while i >= 0: if i * 2 > max_of_size_cup: i = float(i) / 2 else: result = i * n + i * 2 * n break print(min(result, w))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR WHILE VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split(" ")) l = list(map(int, input().split(" "))) l = sorted(l) if l[0] * 2 >= l[int(len(l) / 2)]: if l[int(len(l) / 2)] >= w / 3 * 2 / n: print(w) else: print(l[int(len(l) / 2)] / 2 * n + l[int(len(l) / 2)] * n) else: v = w / 3 if l[0] >= v / n: print(w) else: print(l[0] * 3 * n)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR BIN_OP VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split(" ")) a = list(map(int, input().split(" "))) a.sort(reverse=True) b = a[:n] g = a[n:] portion = min(b[-1], g[-1] * 2) s = portion * n + portion * n / 2 s = min(s, w) print(s)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
inp = input().split() n = int(inp[0]) w = int(inp[1]) cups = sorted(list(map(int, input().split()))) girl = cups[0] boy = cups[n] s = 0 s += min(girl, boy / 2) * 3 * n print(min(s, w))
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) lst = [*map(float, input().split())] lst.sort() res = min(lst[0], lst[n] / 2, w / 3 / n) print(res * 3 * n)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
def maximum_boiling(n, w, a): a.sort() girl_cup = a[0] boy_cup = a[n] base_cup = min(girl_cup, boy_cup / 2) return min(base_cup * 3 * n, w) def read_input(): n, w = [int(i) for i in input().split(" ")] a = [int(i) for i in input().split(" ")] return n, w, a def main(): n, w, a = read_input() print(maximum_boiling(n, w, a)) main()
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING RETURN VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) cups = list(map(int, input().split())) cups.sort() boys_min = cups[n] girl_min = cups[0] tea = girl_min if boys_min < girl_min * 2: tea = boys_min / 2 if tea * 2 * n + tea * n > w: tea = w / (3 * n) print(tea * 3 * n)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
l2 = input().split() n = int(l2[0]) w = int(l2[1]) l = map(int, input().split()) l = sorted(l, reverse=True) minB = 2000000000 minG = 2000000000 for i in range(n): minB = min(minB, l[i]) minG = min(minB, l[i + n]) x = min(minB / 2, minG) print(min(w, n * x * 3))
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = input().split() string = input() ints = map(int, string.split()) alist = [] for num in ints: alist.append(num) alist.sort() if alist[0] * 2 <= alist[int(n)]: g = alist[0] else: g = alist[int(n)] / 2 ans = 3.0 * float(n) * g if ans <= float(w): print(ans) else: print(w)
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
boy_count, amount_of_tea = map(int, input().split()) cups = map(int, input().split()) cups = sorted(cups) smallest_cup_girl = cups[0] smallest_cup_boy = cups[boy_count] tea_unit_needed = boy_count * 3 min_amount = min(float(smallest_cup_girl), smallest_cup_boy / 2) min_amount = min(min_amount, amount_of_tea / (3 * boy_count)) total = min_amount * tea_unit_needed print(total)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
__author__ = "Andrey" n, w = map(int, input().split()) volumes = list(map(int, input().split())) volumes.sort() m = -1 if volumes[0] * 2 <= volumes[n]: possible = 3 * n * volumes[0] if possible <= w: m = max(m, possible) if volumes[n] / 2 <= volumes[0]: possible = volumes[n] / 2 * 3 * n if possible <= w: m = max(m, possible) if w / (3 * n) <= volumes[0] and 2 * w / (3 * n) <= volumes[n]: m = max(m, w) print(m)
ASSIGN VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) capac = list(sorted(map(int, input().split()))) boy = capac[len(capac) // 2] girl = capac[0] print(min(3 * girl * n, 3 / 2 * boy * n, w))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR BIN_OP BIN_OP BIN_OP NUMBER NUMBER VAR VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) array = [] for i in map(int, input().split()): array.append(i) array.sort() x = min(array[0], array[n] / 2) upperBound = w / (3 * n) if x > upperBound: x = upperBound ans = 3 * n * x print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = input().split() n = int(n) w = int(w) k = input().split() k = [int(x) for x in k] x = float(w) / float(3 * n) k.sort() if k[0] < x: x = k[0] if k[n] < 2 * x: x = float(k[n] / 2) ans = float(3 * n * x) print(ans)
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER IF VAR VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, m = map(int, input().split()) c = list(sorted(map(int, input().split()))) print(min(min(c[:n]) * n * 3, min(c[n : 2 * n]) / 2 * n * 3, m))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR NUMBER VAR NUMBER VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = input().split() n = int(n) w = int(w) a = [0] * (2 * n) a = input().split() for i in range(2 * n): a[i] = int(a[i]) a.sort() print(min(a[0], a[n] / 2, w / 3 / n) * 3 * n)
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
import sys [n, w], a = map(int, sys.stdin.readline().split()), sorted( map(int, sys.stdin.readline().split()) ) print(min(w / 3 / n, a[n] / 2, a[0]) * 3 * n)
IMPORT ASSIGN LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR NUMBER NUMBER VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) a = sorted(map(float, input().split())) print(min(a[0], a[n] / 2, w / 3 / n) * 3 * n)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = (int(x) for x in input().split()) a = [int(x) for x in input().split()] a.sort() x = a[0] y = a[n] if x * 2 >= y: print(min(w, y / 2 * 3 * n)) exit() print(min(w, x * 3 * n))
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() maxx = w / (3 * n) t = 0 if a[n] / 2 > a[0]: t = a[0] else: t = a[n] / 2 if t > maxx: print(w) else: print(t * 3 * n)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) arr = list(map(int, input().split())) arr.sort() res = 0 x_min = 0 if arr[0] * 2 <= arr[n]: x_min = float(arr[0]) else: x_min = float(arr[n] / 2) if x_min * 3 * n <= w: res = float(x_min * 3 * n) else: res = float(w) if res % 1 != 0.0: print(res) else: print(int(res))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
I = lambda: map(int, input().split()) n, w = I() a = sorted(I()) t = min(a[0] * 2, a[n]) print(min(t * n * 3 / 2, w))
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
def max_water(friends, w, cups): heso1 = w / (3 * friends) cups.sort() heso2_girl = cups[0] heso3_boy = cups[friends] / 2 min_water = min(heso1, heso2_girl, heso3_boy) return min_water * 3 * friends friends, w = list(map(int, input().split())) cups = list(map(int, input().split())) print(max_water(friends, w, cups))
FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) read = list(map(int, input().split())) read.sort(reverse=True) a = [] b = [] for i in range(n): a.append(read[i]) b.append(read[i + n]) c = [] for i in range(n): c.append(min(a[i] / 2, b[i])) print(min(w, min(c) * 3 * n))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) a = list(map(int, input().split())) b = sorted(a) b1 = b[0:n] b2 = b[n : 2 * n] maxGirl = b1[0] maxBoy = b2[0] maxWater = w / 3 / n maxCapity = 0 total = 0 if maxGirl * 2 > maxBoy: maxCapity = maxBoy / 2 else: maxCapity = maxGirl if maxWater > maxCapity: total = maxCapity * n * 3 else: total = maxWater * n * 3 print(total)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
s = [int(x) for x in input().split(" ")] n, pot = s[0], s[1] cups = sorted([int(x) for x in input().split(" ")])[::-1] for i in range(0, len(cups) // 2): cups[i] = cups[i] / 2 l = len(cups) min_cup = min(cups) y = min_cup * n * 3 print(y if y < pot else pot)
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
A = input().split() B = input().split() a = [int(x) for x in list(B)] a.sort() dt = min(a[0], a[int(A[0])] / 2) * 3 * int(A[0]) print(min(dt, int(A[1])))
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) cups = sorted([int(x) for x in input().split()]) girl = cups[0] boys = cups[n] both = min(girl, boys / 2) print(min(n * both + 2 * n * both, w))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
R = lambda: list(map(int, input().split())) n, w = R() l = R() l.sort() M = l[n] m = l[0] if l[n] > 2 * l[0]: print(min(3 * m * n, w)) else: print(min(1.5 * M * n, w))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = [int(i) for i in input().split()] a = [int(i) for i in input().split()] a.sort() l = len(a) i, j = 0, int(l / 2) if a[i] * 2 <= a[j] and a[j] / 2.0 <= a[i]: print(min(max(a[i], a[j] / 2.0) * 3 * n, w)) elif a[i] * 2 <= a[j]: print(min(a[i] * 3 * n, w)) elif a[j] / 2.0 <= a[i]: print(min(a[j] / 2 * 3 * n, w))
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, k = map(int, input().split()) l = list(map(int, input().split())) l.sort() x = n * 3 * l[0] y = n * 3 * l[n] / 2 print(min(min(x, y), k))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() v1 = a[0] v2 = a[n] q = min(v1, v2 / 2) print(min(w, q * n * 3))
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) a = list(map(int, input().split())) a.sort() bigCup = max(a) def check(x): agar = x / (2 * n * 3) for_girl = agar * 2 for_boy = for_girl * 2 if a[0] < for_girl or a[n] < for_boy: return False return True right = w left = 0 mid = (left + right) / 2 while left + 1e-07 < right: mid = (left + right) / 2 if check(mid): left = mid else: right = mid print(mid)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
(*a,) = map(int, input().split()) (*b,) = sorted(map(int, input().split())) c = min(b[0], b[a[0]] / 2, a[1] / a[0] / 3) print(c * a[0] * 3)
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
inp = lambda: map(int, input().split()) n, w = inp() a = sorted([*inp()]) print(min(w, min(a[n] / 2, a[0]) * n * 3))
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) a = list(map(int, input().split())) a.sort() mina = a[n] maxa = a[0] ans = min(mina / 2.0, maxa) ans = 3.0 * n * ans ans = min(ans, w * 1.0) print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
def main(): n, w = [int(i) for i in input().split(" ")] a = [int(i) for i in input().split(" ")] a = sorted(a) x = w / (3 * n) if x <= a[0] and 2 * x <= a[n]: print(w) else: print(3 * min(a[0], a[n] / 2) * n) main()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR VAR NUMBER BIN_OP NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR
Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} milliliters of water. It turned out that among Pasha's friends there are exactly n boys and exactly n girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: Pasha can boil the teapot exactly once by pouring there at most w milliliters of water; Pasha pours the same amount of water to each girl; Pasha pours the same amount of water to each boy; if each girl gets x milliliters of water, then each boy gets 2x milliliters of water. In the other words, each boy should get two times more water than each girl does. Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. -----Input----- The first line of the input contains two integers, n and w (1 ≤ n ≤ 10^5, 1 ≤ w ≤ 10^9) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. The second line of the input contains the sequence of integers a_{i} (1 ≤ a_{i} ≤ 10^9, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters. -----Output----- Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 2 4 1 1 1 1 Output 3 Input 3 18 4 4 4 2 2 2 Output 18 Input 1 5 2 3 Output 4.5 -----Note----- Pasha also has candies that he is going to give to girls but that is another task...
n, w = map(int, input().split()) a = list(map(int, input().split())) a.sort() if a[0] >= a[n] / 2: m = a[n] * n + a[n] * n / 2 else: m = a[0] * n + a[0] * n * 2 if m > w: print(w) else: print(m)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR