# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
397080 | 2021-05-01T09:55:55 Z | Nicholas_Patrick | Sure Bet (CEOI17_sure) | C++17 | 91 ms | 4368 KB |
#include <cstdio> #include <queue> #include <cmath> #include <algorithm> using namespace std; int main(){ int n; scanf("%d", &n); vector<int> a(n), b(n); for(int i=n; i--;){ double x, y; scanf("%lf%lf", &x, &y); a[i]=x*10000+0.1; b[i]=y*10000+0.1; } sort(a.rbegin(), a.rend()); sort(b.rbegin(), b.rend()); vector<long long> psa(n+1), psb(n+1); psa[0]=psb[0]=0; for(int i=0; i<n; i++){ psa[i+1]=psa[i]+a[i]; psb[i+1]=psb[i]+b[i]; } long long best=0; for(int i=0; i<=n; i++){ int low=0, high=n, mid;//candy[] while(low<=high){ mid=low+high>>1; long long tota=psa[mid]-(mid+i)*10000; long long totb=psb[i]-(mid+i)*10000; best=max(best, min(tota, totb)); if(tota<totb){ low=mid+1; }else{ high=mid-1; } } } printf("%.4lf\n", best/10000.0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 280 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 280 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 208 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 308 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 280 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 208 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 308 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 79 ms | 3964 KB | Output is correct |
18 | Correct | 76 ms | 4000 KB | Output is correct |
19 | Correct | 77 ms | 3908 KB | Output is correct |
20 | Correct | 74 ms | 4040 KB | Output is correct |
21 | Correct | 86 ms | 4368 KB | Output is correct |
22 | Correct | 91 ms | 3996 KB | Output is correct |
23 | Correct | 75 ms | 3992 KB | Output is correct |
24 | Correct | 76 ms | 4000 KB | Output is correct |
25 | Correct | 75 ms | 4116 KB | Output is correct |
26 | Correct | 78 ms | 4292 KB | Output is correct |