Submission #1516057


Source Code Expand

from collections import defaultdict


def can_make(m, k, items):
    n = []
    for item in items:
        w, p = item
        n.append(w * (p - m))
    return sum(sorted(n, reverse=True)[:k]) >= 0


def main():
    N, K = map(int, input().split())
    items = []
    for _ in range(N):
        w, p = map(int, input().split())
        items.append((w, p))

    left, right = 0, 100
    ans = 0
    for _ in range(1000):
        m = (left + right) / 2
        if can_make(m, K, items):
            left = m
            ans = m
        else:
            right = m
            ans = m

    print(ans)

if __name__ == '__main__':
    main()

Submission Info

Submission Time
Task D - 食塩水
User MitI_7
Language Python (3.4.3)
Score 100
Code Size 671 Byte
Status AC
Exec Time 535 ms
Memory 3444 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 535 ms 3444 KB
001.txt AC 71 ms 3316 KB
002.txt AC 449 ms 3444 KB
003.txt AC 82 ms 3316 KB
004.txt AC 460 ms 3444 KB
005.txt AC 444 ms 3444 KB
006.txt AC 458 ms 3444 KB
007.txt AC 385 ms 3444 KB
008.txt AC 459 ms 3444 KB
009.txt AC 65 ms 3316 KB
010.txt AC 457 ms 3444 KB
011.txt AC 242 ms 3316 KB
012.txt AC 530 ms 3444 KB
013.txt AC 213 ms 3316 KB
014.txt AC 465 ms 3444 KB
015.txt AC 366 ms 3444 KB
016.txt AC 454 ms 3444 KB
017.txt AC 303 ms 3444 KB
018.txt AC 450 ms 3444 KB
019.txt AC 330 ms 3444 KB
s0.txt AC 23 ms 3316 KB
s1.txt AC 26 ms 3316 KB