Submission #6367024


Source Code Expand

import sys
input = sys.stdin.readline

# 最大値が赤であるとしてよい

import numpy as np
N = int(input())
XY = np.array([input().split() for _ in range(N)], dtype = np.int64)
X,Y = XY.T
# X \leq Y に変換
Z = X+Y
np.minimum(X,Y,out=X)
Y = Z - X

# 最大のものを赤、最小のものを青とする
# この場合、任意の箱に対して、大きい方を赤、小さい方を青
answer = (X.max() - X.min()) * (Y.max() - Y.min())

red = Y.max() - X.min()
# 青の最小値を決めると全部決まる
# 小さい側でソート -> 左からいくつかを上側、右からいくつかを下側
idx = X.argsort()
X = X[idx]
Y = Y[idx]
Y_min = np.minimum.accumulate(Y)
Y_max = np.maximum.accumulate(Y)
a = Y_max[-1] - Y_min[-1] # 全部上側からとった場合
b = (np.maximum(Y_max[:-1], X[-1]) - np.minimum(X[1:],Y_min[:-1])).min() # 途中まで上側
c = X[-1] - X[0] # 全部下側
answer = min(answer, red * min(a,b,c))

print(answer)

Submission Info

Submission Time
Task E - Ball Coloring
User maspy
Language Python (3.4.3)
Score 700
Code Size 997 Byte
Status AC
Exec Time 448 ms
Memory 92496 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 35
Set Name Test Cases
Sample example0, example1, example2
All div20, div21, div22, div23, div24, example0, example1, example2, maxrand0, maxrand1, maxrand2, maxrand20, maxrand21, maxrand210, maxrand211, maxrand22, maxrand23, maxrand24, maxrand25, maxrand26, maxrand27, maxrand28, maxrand29, maxrand3, maxrand4, smallrand0, smallrand1, smallrand2, smallrand3, smallrand4, sparse0, sparse1, sparse2, sparse3, sparse4
Case Name Status Exec Time Memory
div20 AC 438 ms 92492 KiB
div21 AC 436 ms 92408 KiB
div22 AC 441 ms 92496 KiB
div23 AC 443 ms 92404 KiB
div24 AC 444 ms 92496 KiB
example0 AC 148 ms 12508 KiB
example1 AC 149 ms 12508 KiB
example2 AC 147 ms 12444 KiB
maxrand0 AC 439 ms 92404 KiB
maxrand1 AC 446 ms 92360 KiB
maxrand2 AC 442 ms 92404 KiB
maxrand20 AC 429 ms 92404 KiB
maxrand21 AC 430 ms 92404 KiB
maxrand210 AC 423 ms 92368 KiB
maxrand211 AC 432 ms 92404 KiB
maxrand22 AC 430 ms 92492 KiB
maxrand23 AC 443 ms 92492 KiB
maxrand24 AC 444 ms 92396 KiB
maxrand25 AC 428 ms 92488 KiB
maxrand26 AC 430 ms 92368 KiB
maxrand27 AC 431 ms 92492 KiB
maxrand28 AC 435 ms 92368 KiB
maxrand29 AC 446 ms 92408 KiB
maxrand3 AC 443 ms 92368 KiB
maxrand4 AC 443 ms 92404 KiB
smallrand0 AC 149 ms 12508 KiB
smallrand1 AC 148 ms 12404 KiB
smallrand2 AC 150 ms 12508 KiB
smallrand3 AC 147 ms 12444 KiB
smallrand4 AC 149 ms 12164 KiB
sparse0 AC 435 ms 92352 KiB
sparse1 AC 431 ms 92240 KiB
sparse2 AC 430 ms 92368 KiB
sparse3 AC 437 ms 92404 KiB
sparse4 AC 448 ms 92404 KiB