# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
158888 |
2019-10-19T10:41:00 Z |
brcode |
Sure Bet (CEOI17_sure) |
C++14 |
|
234 ms |
5240 KB |
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
const int MAXN = 3e5+5;
double a[MAXN];
double b[MAXN];
double prefa[MAXN];
double prefb[MAXN];
int pntr;
double ans=0.0;
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i]>>b[i];
}
sort(a+1,a+n+1,greater<double>());
sort(b+1,b+n+1,greater<double>());
for(int i=1;i<=n;i++){
prefa[i] = prefa[i-1]+a[i];
prefb[i] = prefb[i-1]+b[i];
}
double prev = 0.0;
for(int i=1;i<=n;i++){
//cout<<pntr<<endl;
prev = min(prefa[i]-pntr-i,prefb[pntr]-pntr-i);
ans = max(ans,prev);
while(pntr<n && min(prefa[i]-pntr-(double)1-(double)i,prefb[pntr+1]-pntr-(double)1-(double)i)>=(double)prev){
// cout<<min(prefa[i]-pntr-1-i,prefb[pntr+1]-pntr-1-i)<<" "<<prev<<endl;
prev = min(prefa[i]-pntr-(double)1.0-(double)i,prefb[pntr+1]-pntr-(double)1.0-(double)i);
pntr++;
}
ans = max(ans,prev);
}
cout << fixed << showpoint;
cout<<std::setprecision(4)<<ans<<endl;
}
# |
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 |
380 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 |
380 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 |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
4 ms |
504 KB |
Output is correct |
16 |
Correct |
4 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 |
380 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 |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
4 ms |
504 KB |
Output is correct |
16 |
Correct |
4 ms |
376 KB |
Output is correct |
17 |
Correct |
192 ms |
4828 KB |
Output is correct |
18 |
Correct |
192 ms |
4868 KB |
Output is correct |
19 |
Correct |
192 ms |
4828 KB |
Output is correct |
20 |
Correct |
194 ms |
4852 KB |
Output is correct |
21 |
Correct |
224 ms |
5240 KB |
Output is correct |
22 |
Correct |
192 ms |
4924 KB |
Output is correct |
23 |
Correct |
199 ms |
4976 KB |
Output is correct |
24 |
Correct |
192 ms |
4828 KB |
Output is correct |
25 |
Correct |
200 ms |
4984 KB |
Output is correct |
26 |
Correct |
234 ms |
5240 KB |
Output is correct |