Submission #1370330
Source Code Expand
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().solve(); } void solve(){ Scanner sc=new Scanner(System.in); int N=sc.nextInt(); int K=sc.nextInt(); int[] p=new int[N]; int[] w=new int[N]; for(int i=0;i<N;i++){ w[i]=sc.nextInt(); p[i]=sc.nextInt(); } double OK=0; double NG=100; double mid=(OK+NG)/2; for(int t=0;t<100;t++){ mid=(OK+NG)/2; ArrayList<Double> list=new ArrayList<>(); for(int i=0;i<N;i++){ list.add(w[i]*(p[i]-mid)/100); } Collections.sort(list); Collections.reverse(list); double sum=0; for(int i=0;i<K;i++){ sum+=list.get(i); } if(sum>=0){ OK=mid; }else{ NG=mid; } } System.out.println(OK); } }
Submission Info
Submission Time | |
---|---|
Task | D - 食塩水 |
User | kwkm0429 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 100 |
Code Size | 891 Byte |
Status | AC |
Exec Time | 242 ms |
Memory | 31820 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 | 235 ms | 28840 KB |
001.txt | AC | 137 ms | 20180 KB |
002.txt | AC | 221 ms | 27348 KB |
003.txt | AC | 147 ms | 26704 KB |
004.txt | AC | 229 ms | 27980 KB |
005.txt | AC | 237 ms | 30624 KB |
006.txt | AC | 234 ms | 28720 KB |
007.txt | AC | 242 ms | 27712 KB |
008.txt | AC | 234 ms | 29756 KB |
009.txt | AC | 134 ms | 19028 KB |
010.txt | AC | 226 ms | 30496 KB |
011.txt | AC | 195 ms | 25976 KB |
012.txt | AC | 228 ms | 28656 KB |
013.txt | AC | 188 ms | 23564 KB |
014.txt | AC | 224 ms | 31820 KB |
015.txt | AC | 205 ms | 24496 KB |
016.txt | AC | 222 ms | 30428 KB |
017.txt | AC | 198 ms | 28472 KB |
018.txt | AC | 210 ms | 30648 KB |
019.txt | AC | 199 ms | 25852 KB |
s0.txt | AC | 96 ms | 21844 KB |
s1.txt | AC | 101 ms | 18132 KB |