Submission #5418215


Source Code Expand

N, K = map(int, input().split())
WP = sorted([list(map(int, input().split())) for i in range(N)], key=lambda x: x[1], reverse=True)


def check(half):
    cur = 0
    salt = sorted(WP, key=lambda x: x[0]*(x[1]-half), reverse=True)
    for i in range(K):
        cur += salt[i][0] * (salt[i][1]-half)
    if cur >= 0:
        return True
    return False


lower = 0
upper = 100
while upper - lower > 10 ** (-5):
    half = (upper+lower) / 2
    if check(half):
        lower = half
    else:
        upper = half

print(lower)

Submission Info

Submission Time
Task D - 食塩水
User Hirokazu12
Language Python (3.4.3)
Score 100
Code Size 549 Byte
Status AC
Exec Time 37 ms
Memory 3188 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 2
AC × 22
Set Name Test Cases
Sample s0.txt, s1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, s0.txt, s1.txt
Case Name Status Exec Time Memory
000.txt AC 35 ms 3188 KB
001.txt AC 19 ms 3064 KB
002.txt AC 32 ms 3188 KB
003.txt AC 20 ms 3064 KB
004.txt AC 36 ms 3188 KB
005.txt AC 36 ms 3188 KB
006.txt AC 33 ms 3188 KB
007.txt AC 30 ms 3188 KB
008.txt AC 37 ms 3188 KB
009.txt AC 19 ms 3064 KB
010.txt AC 35 ms 3188 KB
011.txt AC 26 ms 3064 KB
012.txt AC 37 ms 3188 KB
013.txt AC 25 ms 3064 KB
014.txt AC 37 ms 3188 KB
015.txt AC 29 ms 3188 KB
016.txt AC 35 ms 3188 KB
017.txt AC 30 ms 3188 KB
018.txt AC 33 ms 3188 KB
019.txt AC 31 ms 3188 KB
s0.txt AC 17 ms 3064 KB
s1.txt AC 18 ms 3064 KB