Submission #1248010
Source Code Expand
#include<iostream> #include<algorithm> using namespace std; typedef long double Ld; #define INF 1e9+9 Ld w[1111], p[1111],y[1111]; int k, n; bool C(Ld x) { for (int i = 0; i < n; i++) { y[i] = p[i] - x*w[i]; } sort(y, y + n); Ld sum = 0; for (int i = 0; i < k; i++)sum += y[n - 1 - i]; return sum >= 0; } int main() { cin >> n >> k; for (int i = 0; i < n; i++)cin >> w[i] >> p[i]; for (int i = 0; i < n; i++)p[i] = w[i] / 100 * p[i]; Ld lb = 0, ub = INF; for (int i = 0; i < 300; i++) { Ld mid = (lb + ub) / 2; if (C(mid))lb = mid; else ub = mid; } printf("%.13Lf\n", ub*100); getchar(); getchar(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 食塩水 |
User | Rho17 |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 670 Byte |
Status | AC |
Exec Time | 22 ms |
Memory | 256 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 | 21 ms | 256 KB |
001.txt | AC | 2 ms | 256 KB |
002.txt | AC | 21 ms | 256 KB |
003.txt | AC | 3 ms | 256 KB |
004.txt | AC | 22 ms | 256 KB |
005.txt | AC | 21 ms | 256 KB |
006.txt | AC | 21 ms | 256 KB |
007.txt | AC | 18 ms | 256 KB |
008.txt | AC | 21 ms | 256 KB |
009.txt | AC | 2 ms | 256 KB |
010.txt | AC | 21 ms | 256 KB |
011.txt | AC | 9 ms | 256 KB |
012.txt | AC | 21 ms | 256 KB |
013.txt | AC | 8 ms | 256 KB |
014.txt | AC | 22 ms | 256 KB |
015.txt | AC | 16 ms | 256 KB |
016.txt | AC | 21 ms | 256 KB |
017.txt | AC | 12 ms | 256 KB |
018.txt | AC | 21 ms | 256 KB |
019.txt | AC | 14 ms | 256 KB |
s0.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |