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;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define fi first
#define se second
#define int long long
#define pii pair<int,int>
#define piii pair<int, pair<int, int>>
#define v(int) vector<int>
#define si size()
#define foe(i,a,b) for(int i=a;i<=b;++i)
#define fol(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define Bit(mask,i) (1<<i)&mask
#define offBit(mask,i) (1<<i)^mask
#define onBit(mask,i) (1<<i)mask
#define CNT(x) __builtin_popcountll(x)
const int mod = 1e9+7;
const int base = 2309;
const int inf = 1e18;
const int N = 1e6+10;
const int LG = 20;
// ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄▄ ▄ ▄▄▄▄
// █▄▄█ █ █ █ █ █▄▄█ █ █ ██ █ █ ▄▄
// █ █ █▄▄█ █▄▄█ █ █ █▄▄█ █ ██ █▄▄█
int n;
double a[N], b[N];
double ans, A, B;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
fol(i,0,n)
{
cin >> a[i] >> b[i];
}
sort(a, a + n, greater<double>());
sort(b, b + n, greater<double>());
int l = 0, r = 0;
while(l < n || r < n)
{
if((A < B && l < n) || r == n)
A += a[l++];
else
B += b[r++];
A --;
B --;
ans = max(ans, min(A, B));
}
cout << fixed << setprecision(4) << ans << "\n";
cerr << "\n" << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
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... |