# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127008 | 2019-07-08T19:13:47 Z | Lawliet | Sure Bet (CEOI17_sure) | C++14 | 220 ms | 6088 KB |
#include <bits/stdc++.h> #define MAX 100010 using namespace std; int n; double ans = -4000000.0; double a[MAX]; double b[MAX]; double ansA[MAX]; double ansB[MAX]; double mxAnsB[MAX]; bool test(double k) { for(int qtdA = 0 ; qtdA <= n ; qtdA++) { double aux = ansA[qtdA] - k; //printf("===== qtdA = %d %lf\n",qtdA,aux); if(ansA[qtdA] < k) continue; int mxQtdB = floor( aux ); mxQtdB = min(mxQtdB , n); //printf("----------------- qtdA = %d mxQtdB = %d\n",qtdA,mxQtdB); if(mxAnsB[ mxQtdB ] - qtdA >= k) return true; } return false; } double bs() { double l = 0, r = 200000000.0; for(int cnt = 0 ; cnt <= 500 ; cnt++) { double m = (l + r)/2; //printf("l = %lf r = %lf m = %lf\n",l,r,m); if(test(m)) l = m; else r = m; } return l; } void init() { sort(a + 1 , a + n + 1); sort(b + 1 , b + n + 1); for(int g = 1 ; g <= n ; g++) { ansA[g] = ansA[g - 1] + a[n - g + 1]; ansB[g] = ansB[g - 1] + b[n - g + 1]; //printf("g = %d ansA = %lf\n",g,ansA[g]); } for(int g = 1 ; g <= n ; g++) { ansA[g] -= g; ansB[g] -= g; mxAnsB[g] = max(mxAnsB[g - 1] , ansB[g]); } } int main() { scanf("%d",&n); for(int g = 1 ; g <= n ; g++) scanf("%lf %lf",&a[g],&b[g]); init(); printf("%.4lf\n",bs()); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 376 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 4 ms | 376 KB | Output is correct |
15 | Correct | 4 ms | 380 KB | Output is correct |
16 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 376 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 4 ms | 376 KB | Output is correct |
15 | Correct | 4 ms | 380 KB | Output is correct |
16 | Correct | 3 ms | 376 KB | Output is correct |
17 | Correct | 168 ms | 5560 KB | Output is correct |
18 | Correct | 193 ms | 5624 KB | Output is correct |
19 | Correct | 207 ms | 5616 KB | Output is correct |
20 | Correct | 220 ms | 5752 KB | Output is correct |
21 | Correct | 133 ms | 6008 KB | Output is correct |
22 | Correct | 168 ms | 5624 KB | Output is correct |
23 | Correct | 194 ms | 5692 KB | Output is correct |
24 | Correct | 206 ms | 5628 KB | Output is correct |
25 | Correct | 220 ms | 5624 KB | Output is correct |
26 | Correct | 125 ms | 6088 KB | Output is correct |