# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
278692 | BeanZ | Sure Bet (CEOI17_sure) | C++14 | 132 ms | 5408 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 15;
long double a[100005], b[100005];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("VietCT.INP", "r")){
freopen("VietCT.INP", "r", stdin);
freopen("VietCT.OUT", "w", stdout);
}
ll n;
cin >> n;
for (int i = 1; i <= n; i++){
cin >> a[i] >> b[i];
}
sort(a + 1, a + n + 1, greater<long double>());
sort(b + 1, b + n + 1, greater<long double>());
ll l = 1, r = 1;
long double sum1 = a[1], sum2 = b[1];
long double ans = 0;
while (true){
ans = max(ans, min(sum1, sum2) - (long double)(l + r));
if (sum1 <= sum2 && l < n){
l++;
sum1 += a[l];
} else if (r < n){
r++;
sum2 += b[r];
} else {
break;
}
}
cout << fixed << setprecision(4) << ans;
}
/*
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |