제출 #1356382

#제출 시각아이디문제언어결과실행 시간메모리
1356382vjudge1구경하기 (JOI13_watching)C++20
0 / 100
0 ms344 KiB
// cd /mnt/c/users/murad/onedrive/dokumente
/// https://open.spotify.com/intl-tr/track/13XGeumHl6payK5U9fI0R7?si=c27aa63e897a4bcb
/*
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
'*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define int long long
#define YES cout << "YES" << '\n';
#define NO cout << "NO" << '\n';
#define Yes cout << "Yes" << '\n';
#define No cout << "No" << '\n';
#define no cout << "no" << '\n';
#define yes cout << "yes" << '\n';
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define pf push_front
#define M_PI 3.14159265358979323846
#define vi vector<long long>
#define pii pair<long long, long long>
#define vii vector<pair<long long, long long>>
#define vvi vector<vector<long long>>
#define FOR0(i, n) for (int i = 0; i < n; ++i)
#define FOR1(i, n) for (int i = 1; i <= n; ++i)
const long long kurdistan = 0;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long LINF = 4e18;
const long long LOG = 20;
const long long MAXM = 50000;
const long long MAXN = 200000 + 5;
const long long sz = 1e7 + 5;
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

template <typename T>
void print(const vector<T> &v)
{
    for (auto &x : v)
    {
        cout << x << ' ';
    }
    cout << '\n';
}

template <typename T>
void input(vector<T> &v)
{
    for (auto &x : v)
    {
        cin >> x;
    }
}

int ebob(int a, int b)
{
    int g = std::gcd(a, b);
    return g;
}
int ekob(int a, int b)
{
    int g = std::gcd(a, b);
    return (a / g) * b;
}

using namespace __gnu_pbds;
template <typename T>
using indexed_set = tree<
    T,
    null_type,
    less<T>,
    rb_tree_tag,
    tree_order_statistics_node_update>;
template <typename T>
using indexed_multiset = tree<
    pair<T, int>,
    null_type,
    less<pair<T, int>>,
    rb_tree_tag,
    tree_order_statistics_node_update>;
///--------------------TEMPLATE END-------------------------------------

int n, p, q;
vi a(2010);

bool f(int w)
{
    int i = 0;
    int p1 = p;
    int q1 = q;
    while (i < n)
    {
        if (p1 + q1 == 0)
        {
            return false;
        }
        int best = 0;
        bool lr = false;
        if (q1 > 0)
        {
            int lim = a[i] + 2 * w;
            int j = i;
            while (j < n && a[j] <= lim)
            {
                j++;
            }
            if (j - i > best)
            {
                best = j - i;
                lr = true;
            }
        }
        if (p1 > 0)
        {
            int lim = a[i] + w;
            int j = i;
            while (j < n && a[j] <= lim)
            {
                j++;
            }
            if (j - i > best)
            {
                best = j - i;
                lr = false;
            }
        }
        if (best == 0)
        {
            return false;
        }
        if (lr)
        {
            q1--;
        }
        else
        {
            p1--;
        }
        i += best;
    }
    return true;
}

void _()
{
    cin >> n >> p >> q;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    sort(all(a));
    int l = 1;
    int r = 1e9;
    int res = r;
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        if (f(mid))
        {
            res = mid;
            r = mid - 1;
        }
        else
        {
            l = mid + 1;
        }
    }
    cout << res << '\n';
}

signed main()
{
    fastio int t = 1;
    // cin >> t;
    while (t--)
    {
        _();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...