# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1171142 | Nelt | Sure Bet (CEOI17_sure) | C++20 | 61 ms | 3400 KiB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T, typename key = less<T>>
using ordered_set = tree<T, null_type, key, rb_tree_tag, tree_order_statistics_node_update>;
void solve()
{
ll n;
cin >> n;
long double a[n + 1], b[n + 1];
for (ll i = 1; i <= n; i++) cin >> a[i] >> b[i];
sort(a + 1, a + n + 1, greater());
sort(b + 1, b + n + 1, greater());
a[0] = b[0] = 0;
for (ll i = 1; i <= n; i++) a[i] += a[i - 1], b[i] += b[i - 1];
long double ans = 0;
for (ll i = 0; i <= n; i++)
{
ll pos = lower_bound(b, b + n + 1, a[i]) - b;
if (pos <= n) ans = max(ans, a[i] - (pos + i));
pos--;
if (pos >= 0) ans = max(ans, b[pos] - (pos + i));
}
cout << setprecision(4) << fixed << ans << endl;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |