Submission #237266

# Submission time Handle Problem Language Result Execution time Memory
237266 2020-06-05T14:59:16 Z uacoder123 Watching (JOI13_watching) C++14
0 / 100
6 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))

typedef long long int lli;
typedef pair <lli,lli> ii;
typedef pair <ii,lli> iii;
typedef vector <lli> vi;
set<int> arr;
int s,l;
int check(int w)
{
    int c1=1,s1=s,l1=l;
    auto it=arr.begin();
    while(it!=arr.end())
    {
        int c=(*it);
        while(it!=arr.end()&&(*it)<=w+c-1)
            it++;
        if(((it!=arr.end()&&(*it)<=2*w+c-1)||s1==0)&&l1>0)
        {
            l1--;
            while(it!=arr.end()&&(*it)<=2*w+c-1)
                it++;
        }
        else if(s1>0)
            s1--;
        else
            {
                c1=0;
                break;
            }
    }
    return(c1);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli test=1;
  for(;test>0;--test)
  {
  int n,f,ans=1000000000,le=1,ri=1000000000;
  cin>>n>>s>>l;
  for(int i=0;i<n;++i)
  {
    cin>>f;
    arr.insert(f);
  }
  while(le<ri)
  {
    int m=(le+ri)/2;
    if(check(m))
    {
        ans=m;
        ri=m-1;
    }
    else
        le=m+1;
  }
  cout<<ans<<endl;
  }
  return(0);
} 
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -