Submission #934543

# Submission time Handle Problem Language Result Execution time Memory
934543 2024-02-27T14:30:58 Z a_l_i_r_e_z_a Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 2392 KB
// In the name of God
// Hope is last to die

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
// #define int long long
#define S second
#define F first
#define mp make_pair
#define smax(x, y) (x) = max((x), (y))
#define smin(x, y) (x) = min((x), (y))
#define all(x) (x).begin(), (x).end()
#define len(x) ((int)(x).size())

const int maxn = 1e5 + 5;
const int inf = 1e9 + 7;
int n;
double a[maxn], b[maxn], psa[maxn], psb[maxn];

int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    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);
    reverse(a + 1, a + n + 1);
    reverse(b + 1, b + n + 1);
    for(int i = 1; i <= n; i++){
        psa[i] = psa[i - 1] + a[i];
        psb[i] = psb[i - 1] + b[i];
    }
    double ans = 0;
    double mx = 0;
    int cur = 0;
    for(int i = 0; i <= n; i++){
        while(cur <= n && psb[cur] <= psa[i]){
            smax(mx, psb[cur] - cur);
            cur++;
        }
        smax(ans, mx - i);
    }
    mx = 0;
    cur = 0;
    for(int i = 0; i <= n; i++){
        while(cur <= n && psa[cur] <= psb[i]){
            smax(mx, psa[cur] - cur);
            cur++;
        }
        smax(ans, mx - i);
    }
    cout << setprecision(10) << fixed << ans << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -