Submission #498380

#TimeUsernameProblemLanguageResultExecution timeMemory
498380MukhitaliSure Bet (CEOI17_sure)C++17
0 / 100
0 ms204 KiB
//bit chass 1 #include <bits/stdc++.h> #define x first #define y second #define el "\n" #define ll long long #define pb push_back #define pll pair <ll, ll> #define pii pair <int, int> #define all(x) x.begin(), x.end() #define lcm(x,y) x * y / __gcd(x, y) #define ibase ios_base::sync_with_stdio(0), cin.tie(0) using namespace std; const int N = 3e5 + 5, inf = 1e9 + 7, M = 2e6, MM = 2e6 + 5, K = 300; const ll MI = 2e18; const double P = 3.14; double a[N], b[N]; int n; double get(int l) { double mx = -inf, s1 = 0, s2 = 0; if (l <= n) { int m = n - l + 1; for (int i = n; i >= n - l + 1; i--) s1 += a[i]; for (int i = n; i >= n - l + 1; i--) { mx = max(mx, min(s1 - l, s2 - l)); s1 -= a[m]; m++; s2 += b[i]; } } else { int m = 1; for (int i = 1; i <= n; i++) s1 += a[i]; for (int i = n; i >= n - (l - n) + 1; i--) s2 += b[i]; for (int i = n - (l - n); i >= 1; i--) { mx = max(mx, min(s1 - l, s2 - l)); s1 -= a[m]; m++; s2 += b[i]; } } return mx; } void solve() { // int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i] >> b[i]; sort(a + 1, a + n + 1); sort(b + 1, b + n + 1); int l = 0, r = 2 * n, m1 = l + 1, m2 = r - 1; while (r - l > 3) { m1 = l + (r - l) / 3; m2 = r - (r - l) / 3; if (get(m1) > get(m2)) r = m2; else l = m1; } cout << fixed << setprecision(4) << max(get(l), max(get(m1), max(get(m2), get(r)))); } int main() { ibase; int T = 1; // cin >> T; for (int i = 1; i <= T; i++) { // cout << "Case " << i << ": "; solve(); cout << el; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...