# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65777 | 2018-08-08T17:57:34 Z | naderjemel | Sure Bet (CEOI17_sure) | C++14 | 101 ms | 17072 KB |
#include <bits/stdc++.h> using namespace std; const long long INF=2e9; int main(){ int n; scanf("%d",&n); vector<double> as,bs; for(int i=0;i<n;i++){ double a,b; scanf("%lf %lf",&a,&b); as.push_back(a); bs.push_back(b); } sort(as.begin(),as.end()); sort(bs.begin(),bs.end()); reverse(as.begin(),as.end()); reverse(bs.begin(),bs.end()); int i=0,j=0; double rs=0.0,us=0.0; double nowa=0,nowb=0; while(i<n || j<n){ if(i<n && j<n){ if(nowa<=nowb && i<n){ nowa+=as[i]; i++; us+=1.0; } else if(j<n){ nowb+=bs[j]; j++; us+=1.0; } } else if(i<n){ nowa+=as[i]; i++; us+=1.0; } else{ nowb+=bs[j]; j++; us+=1.0; } rs=max(rs,min(nowa-us,nowb-us)); } printf("%.4lf\n", (double)rs); }
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 | 3 ms | 444 KB | Output is correct |
4 | Correct | 3 ms | 468 KB | Output is correct |
5 | Correct | 2 ms | 520 KB | Output is correct |
6 | Correct | 3 ms | 520 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 | 3 ms | 444 KB | Output is correct |
4 | Correct | 3 ms | 468 KB | Output is correct |
5 | Correct | 2 ms | 520 KB | Output is correct |
6 | Correct | 3 ms | 520 KB | Output is correct |
7 | Correct | 3 ms | 532 KB | Output is correct |
8 | Correct | 2 ms | 572 KB | Output is correct |
9 | Correct | 2 ms | 588 KB | Output is correct |
10 | Correct | 3 ms | 624 KB | Output is correct |
11 | Correct | 2 ms | 624 KB | Output is correct |
12 | Correct | 4 ms | 640 KB | Output is correct |
13 | Correct | 4 ms | 656 KB | Output is correct |
14 | Correct | 3 ms | 672 KB | Output is correct |
15 | Correct | 4 ms | 688 KB | Output is correct |
16 | Correct | 3 ms | 808 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 | 3 ms | 444 KB | Output is correct |
4 | Correct | 3 ms | 468 KB | Output is correct |
5 | Correct | 2 ms | 520 KB | Output is correct |
6 | Correct | 3 ms | 520 KB | Output is correct |
7 | Correct | 3 ms | 532 KB | Output is correct |
8 | Correct | 2 ms | 572 KB | Output is correct |
9 | Correct | 2 ms | 588 KB | Output is correct |
10 | Correct | 3 ms | 624 KB | Output is correct |
11 | Correct | 2 ms | 624 KB | Output is correct |
12 | Correct | 4 ms | 640 KB | Output is correct |
13 | Correct | 4 ms | 656 KB | Output is correct |
14 | Correct | 3 ms | 672 KB | Output is correct |
15 | Correct | 4 ms | 688 KB | Output is correct |
16 | Correct | 3 ms | 808 KB | Output is correct |
17 | Correct | 81 ms | 3908 KB | Output is correct |
18 | Correct | 91 ms | 5140 KB | Output is correct |
19 | Correct | 87 ms | 6812 KB | Output is correct |
20 | Correct | 101 ms | 7876 KB | Output is correct |
21 | Correct | 79 ms | 9628 KB | Output is correct |
22 | Correct | 81 ms | 10968 KB | Output is correct |
23 | Correct | 92 ms | 12520 KB | Output is correct |
24 | Correct | 90 ms | 13812 KB | Output is correct |
25 | Correct | 92 ms | 15084 KB | Output is correct |
26 | Correct | 99 ms | 17072 KB | Output is correct |