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;
typedef long long ll;
typedef long double ld;
ld niz1[100005];
ld niz2[100005];
int main() {
ios_base::sync_with_stdio(false);
cout.precision(4);
cout << fixed;
int n;
cin >> n;
for(int i=0; i<n; i++){
cin >> niz1[i];
cin >> niz2[i];
niz1[i]--;
niz2[i]--;
}
sort(niz1, niz1+n);
sort(niz2, niz2+n);
reverse(niz1, niz1+n);
reverse(niz2, niz2+n);
int j=0;
ld res1=0;
ld res2=0;
ld maxres=0;
for(int i=0; i<n; i++){
res1 += niz1[i];
while(j < n && min(res1-j, res2-i-1) < min(res1-j-1, res2+niz2[j]-i-1)){
res2 += niz2[j];
j++;
}
maxres = max(maxres, min(res1-j, res2-i-1));
}
cout << maxres;
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... |