Submission #1873888
Source Code Expand
def func(n, k, wp, y, x) n.times{|i| w, p = wp[i] y[i] = w * (p - x) } y.sort!.reverse! sum = 0 k.times{|i| sum += y[i] } return sum >= 0 end n,k = gets.split.map &:to_i wp = n.times.map{w,p = gets.split.map &:to_i} ok = 0.0 ng = 100.0 y = Array.new(n, 0.0) for i in 0..100 mid = (ok + ng)/2 if func(n, k, wp, y, mid) then ok = mid else ng = mid end end p ng
Submission Info
Submission Time | |
---|---|
Task | D - 食塩水 |
User | sca1l |
Language | Ruby (2.3.3) |
Score | 100 |
Code Size | 447 Byte |
Status | AC |
Exec Time | 79 ms |
Memory | 1788 KB |
Compile Error
./Main.rb:18: warning: `&' interpreted as argument prefix ./Main.rb:19: warning: `&' interpreted as argument prefix ./Main.rb:19: warning: assigned but unused variable - w ./Main.rb:19: warning: assigned but unused variable - p ./Main.rb:25: warning: assigned but unused variable - i
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 | 77 ms | 1788 KB |
001.txt | AC | 13 ms | 1788 KB |
002.txt | AC | 74 ms | 1788 KB |
003.txt | AC | 24 ms | 1788 KB |
004.txt | AC | 78 ms | 1788 KB |
005.txt | AC | 76 ms | 1788 KB |
006.txt | AC | 73 ms | 1788 KB |
007.txt | AC | 64 ms | 1788 KB |
008.txt | AC | 79 ms | 1788 KB |
009.txt | AC | 13 ms | 1788 KB |
010.txt | AC | 77 ms | 1788 KB |
011.txt | AC | 41 ms | 1788 KB |
012.txt | AC | 79 ms | 1788 KB |
013.txt | AC | 36 ms | 1788 KB |
014.txt | AC | 79 ms | 1788 KB |
015.txt | AC | 61 ms | 1788 KB |
016.txt | AC | 76 ms | 1788 KB |
017.txt | AC | 52 ms | 1788 KB |
018.txt | AC | 74 ms | 1788 KB |
019.txt | AC | 57 ms | 1788 KB |
s0.txt | AC | 7 ms | 1788 KB |
s1.txt | AC | 7 ms | 1788 KB |