Submission #1516005
Source Code Expand
from collections import defaultdict def main(): N, K = map(int, input().split()) items = [] for _ in range(N): w, p = map(int, input().split()) items.append((w, p * w)) used = [False] * N total = [0, 0] while sum(used) < K: best_i = used.index(False) for i in range(len(items)): if used[i]: continue tmp = [total[0] + items[i][0], total[1] + items[i][1]] best = [total[0] + items[best_i][0], total[1] + items[best_i][1]] if tmp[1] * best[0] > best[1] * tmp[0]: best_i = i used[best_i] = True total[0] += items[best_i][0] total[1] += items[best_i][1] print(total[1] / total[0]) if __name__ == '__main__': main()
Submission Info
Submission Time | |
---|---|
Task | D - 食塩水 |
User | MitI_7 |
Language | Python (3.4.3) |
Score | 100 |
Code Size | 817 Byte |
Status | AC |
Exec Time | 407 ms |
Memory | 3444 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
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 | 298 ms | 3444 KB |
001.txt | AC | 23 ms | 3316 KB |
002.txt | AC | 92 ms | 3444 KB |
003.txt | AC | 26 ms | 3316 KB |
004.txt | AC | 375 ms | 3444 KB |
005.txt | AC | 366 ms | 3444 KB |
006.txt | AC | 87 ms | 3444 KB |
007.txt | AC | 134 ms | 3444 KB |
008.txt | AC | 388 ms | 3444 KB |
009.txt | AC | 26 ms | 3316 KB |
010.txt | AC | 316 ms | 3444 KB |
011.txt | AC | 116 ms | 3316 KB |
012.txt | AC | 407 ms | 3444 KB |
013.txt | AC | 69 ms | 3316 KB |
014.txt | AC | 396 ms | 3444 KB |
015.txt | AC | 76 ms | 3444 KB |
016.txt | AC | 307 ms | 3444 KB |
017.txt | AC | 174 ms | 3444 KB |
018.txt | AC | 98 ms | 3444 KB |
019.txt | AC | 225 ms | 3444 KB |
s0.txt | AC | 21 ms | 3316 KB |
s1.txt | AC | 21 ms | 3316 KB |