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>
#define ll long long
#define ld long double
#define all(v) begin(v), end(v)
#define pi pair<int, int>
#define vi vector<int>
using namespace std;
const int maxn = 1e5+3;
int n;
double a[maxn], b[maxn];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i] >> b[i];
a[i] = a[i] - 1.0;
b[i] = b[i] - 1.0;
}
sort(a+1, a+n+1, greater<double>());
sort(b+1, b+n+1, greater<double>());
int i = 1, j = 1;
double res = 0;
double suma = 0, sumb = 0;
while(i <= n){
suma += a[i];
i++;
while(j <= n && min(suma - j + 1, sumb - i + 1) <= min(suma - j, sumb + b[j] - i + 1)){
sumb += b[j];
j++;
}
res = max(res, min(suma - j + 1, sumb - i + 1));
}
cout << fixed << setprecision(4) << res;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |