제출 #1327445

#제출 시각아이디문제언어결과실행 시간메모리
1327445nobasistaken구경하기 (JOI13_watching)C++20
0 / 100
1 ms332 KiB
#include<bits/stdc++.h>
#include <set>
using namespace std;
#define int long long
//#define endl '\n'
bool testcases=0;
int dx[]={0,-1,0,1};
int dy[]={-1,0,1,0};
const int MOD=1e18;
const int inf=1e18;
const int mynum=21;
const int N=2e5;
const int siz=N+mynum;
const int int32=4294967295;
bool check(int mid,vector<int>& v,int p,int q,int n){
    int i=1;
    while(i<=n){
        int j=i;
        int srange=v[i]+mid-1;
        while(j<=n and v[j]<=srange)j++;
        int k=i;
        int brange=v[i]+2*mid-1;
        while(k<=n and v[k]<=brange)k++;
        if(q>0 and k>j){
            q--;
            i=k;
        }
        else if(p>0){
            p--;
            i=j;
        }
        else if(q>0){
            q--;
            i=k;
        }
        else{
            return false;
        }
    }
    return true;
}
int bs(vector<int>& v,int p,int q,int n){
    int l=1,r=1e9,mid,ans;
    while(l<=r){
        mid=(l+r)/2;
        if(check(mid,v,p,q,n))r=mid-1,ans=mid;
        else l=mid+1;
    }
    return ans;
}
void solve(){
    int n,p,q;
    cin>>n>>p>>q;
    vector<int> v(n+1);
    v[0]=-mynum;
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    cout<<bs(v,p,q,n);
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    if(testcases)cin>>t;
    while(t--){
        solve();
    }
}
/*
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
------------------------------------------##+----------+##------------------------------------------
----------------------------------------+###------------###+----------------------------------------
--------------------------+###------------##------------##------------###+--------------------------
--------------------------+###+------#+#--##+--#+##+#---##--#+#-------###---------------------------
----------+---------------++-+###-----##++##+-+#-++-++-+##++##-----###+-++---------------+----------
----------+###+---------------####+##+#+##-#+--+#--#+--+#-##+####+####---------------+###+----------
---------#####+##++--------+++#######+---##++----+-----++##---+#######+++--------++##+#####---------
-----+#++##-######-##-------##++#####+----+##+--++----+##+----######++#+-------##-######-##++#+-----
--------#################-----+##+####---+++##--+++---##+++---####+##+-----#################--------
-------##---############-+++---####+##---++##---#++#---##++---##+####---+++-############---##-------
-------+-----##############+---######-+--+##+---##+#+--+##+--+-######---+##############-----#-------
-------+-##+--+#############+---+##++-#---#+----##+#+---+#---#-++##+---+#############+--+##-+-------
---------###---###+++#########---####-##-------+##+#+-------##-####---#########+++###---###---------
----------+###--+#######++######+--++-##+----+-###+##-+----+#+-++--+######++#######+--###+----------
----------+####---+###########++##++--+----+++####+###+-++------++##++###########+---####+----------
--------+##+####---+###############+--------###++++-+###--------+###############----####+##+--------
---------++###+##+--++---+++++++++++-#------+##-+##+-##+------#-+++++++++++----#--+##+###++---------
---------+-+#####+-+###############++-#+-----++-+###-++-----+#-+################+-+#####+-+---------
---------+#########+-+#----++++#######-##+---#+++##+++#---+##-#######++++----#+-+#########+---------
----------#++########+----#########+++#+--++####+#++#####+--+#+-+#########-----########++#----------
----------#---+#+######-----#+----+####-+++##+#+####+#+##+++-####+----+#-----######+#----++---------
---------#####-#####++#-#---------+++--######++#++++#+#######+++++---------#-#++#####-#####---------
----------++#####+-+###+##------+###+++#######+######+#######+++###+------##-###+-+#####++----------
----------++#--+#######++#------#++##+-+---#+##########+#+--+--##++#------##-#######+--#++----------
----------------#######+###----###+----------##########----------+###----###+#######----------------
----------------+#+####-###+---##-------------+###+##+--------+----##---+###-####+#+----------------
----------------+#-###+-+#+--+##---##+---++--##########--++---+##---##---+#+-+###-#+----------------
----------------+#--+###----+##---+#----###+-##########-+###----#+---##-----###+--#+----------------
----------------+#--+##----+##---+#+----+#--+##########---#+----+#+---##-----##---#+----------------
----------------+#---#-----##----#+-----+#--###########+--#+-----+#----##-----#---#+----------------
---------------------+----##+---##------#+--+##########+--+#------##---+##----+---------------------
---------------------+---##+---+#------+#-----########-----#+------#+---+##---+---------------------
---------------------+---##----#-------+#----+########+----#+-------#----##+--+---------------------
---------------------+---#----++-------+#-----########-----#+-------#+----#+--+---------------------
---------------------+---#----+---------#----+########-----#+-------++----+---+---------------------
---------------------+---#----+---------+-----########-----#+--------+----+---+---------------------
-------------------------#--------------+-----########-----+--------------#+------------------------
-------------------------+--------------+-----########-----+--------------+-------------------------
-------------------------#--------------------+#######--------------------#+------------------------
------------------------+#--------------------########--------------------#+------------------------
------------------+---#+##--------------------#######+--------------------##+#--++------------------
------------------###+####+#+--------------+#+#+####+++#+--------------+#+####+###------------------
-------------------##+####+#+-+#+----------###-+####+-###----------+#--+#+####+#+-------------------
--------------------########+##---------+##+-#--++#+--#-+##+--------+##+########--------------------
----------------+++++############+------+###--#------#--###+------+###########+++++-----------------
----------------+-----+-----++-+--+---+-+--##+##-+#-#++#+--+-#---+--+-++-----+-----+----------------
--------------------------------------+##+---###+##+###---+##+--------------------------------------
-----------------------------------------+###++#-+#-#+++##+-----------------------------------------
-------------------------------------------+++++-+#-++++--------------------------------------------
-------------------------------------++---+++++++++++++++++--++-------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------

\\\\\\
Machine
I will cut you down
break you apart
splay the gore of your profane form across the stars
I will grind you down until the very sparks cry for mercy
My hands shall relish
Ending you
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...