Submission #3789933


Source Code Expand

def ok(mid):
    shoku=[w[i]*(p[i]-mid) for i in range(N)]
    shoku.sort(reverse=True)

    return sum(shoku[:K])>=0

N,K =map(int, input().split())
w,p =[],[]

for i in range(N):
    wi,pi=map(int,input().split())
    w.append(wi)
    p.append(pi)

top=100
btm=0

for i in range(100):
    mid=(top+btm)/2

    if ok(mid):
        btm=mid
    else:
        top=mid

answer=(top+btm)/2

print(answer)

Submission Info

Submission Time
Task D - 食塩水
User Masa0u0
Language Python (3.4.3)
Score 100
Code Size 427 Byte
Status AC
Exec Time 68 ms
Memory 3064 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 67 ms 3064 KB
001.txt AC 24 ms 3064 KB
002.txt AC 67 ms 3064 KB
003.txt AC 25 ms 3064 KB
004.txt AC 68 ms 3064 KB
005.txt AC 65 ms 3064 KB
006.txt AC 67 ms 3064 KB
007.txt AC 61 ms 3064 KB
008.txt AC 67 ms 3064 KB
009.txt AC 23 ms 3064 KB
010.txt AC 67 ms 3064 KB
011.txt AC 44 ms 3064 KB
012.txt AC 68 ms 3064 KB
013.txt AC 41 ms 3064 KB
014.txt AC 68 ms 3064 KB
015.txt AC 58 ms 3064 KB
016.txt AC 67 ms 3064 KB
017.txt AC 50 ms 3064 KB
018.txt AC 66 ms 3064 KB
019.txt AC 54 ms 3064 KB
s0.txt AC 19 ms 3064 KB
s1.txt AC 19 ms 3064 KB