# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
812680 |
2023-08-07T10:05:57 Z |
Cookie |
Sure Bet (CEOI17_sure) |
C++14 |
|
0 ms |
340 KB |
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
//ifstream fin("FEEDING.INP");
//ofstream fout("FEEDING.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const int base = 74;
const ll mod = 1e9 + 7, inf = 1e9, mxv = 1005, mxn = 2e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
ld a[mxn + 1], b[mxn + 1], pa[mxn + 1], pb[mxn + 1];
ld val(int x, int y){
return(min(pa[x], pb[y]) - (x + y));
}
signed main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i] >> b[i];
}
ld ans = 0;
sort(a + 1, a + n + 1, greater<ld>()); sort(b + 1, b + n + 1, greater<ld>());
for(int i = 1; i <= n; i++){
pa[i] = pa[i - 1] + a[i]; pb[i] = pb[i - 1] + b[i];
}
for(int i = 1; i <= 2 * n; i++){
int l = 0, r = min(n, i);
while(l <= r){
int m1 = l + (r - l) / 3.0, m2 = r - (r - l) / 3.0;
ld v1 = val(m1, i - m1), v2 = val(m2, i - m2);
if(v1 < v2){
ans = max(ans, v2); l = m1 + 1;
}else{
ans = max(ans, v1); r = m2 - 1;
}
}
}
cout << fixed << setprecision(4) << ans;
return(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |