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 rep(i , j , k) for(int i = j; i < k; i++)
#define pb push_back
typedef long long ll;
typedef pair<int , int> pii;
typedef vector<int> vi;
template<typename S, typename T>
inline bool smin(S &l, T r) { return l < r ? 0 : (l = r, 1); }
template<typename S, typename T>
inline bool smax(S &l, T r) { return r < l ? 0 : (l = r, 1); }
constexpr int N = 1e5 + 10;
int n, l, r;
double A, B, a[N], b[N], res;
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
rep(i , 0 , n)
cin >> a[i] >> b[i];
sort(a , a + n, greater<double>());
sort(b , b + n, greater<double>());
while (l < n || r < n) {
if ((A < B && l < n) || r == n)
A += a[l++];
else
B += b[r++];
A--;
B--;
smax(res , min(A , B));
}
cout << fixed << setprecision(4) << res << endl;
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... |