Submission #895527

# Submission time Handle Problem Language Result Execution time Memory
895527 2023-12-30T07:35:25 Z nbphong Watching (JOI13_watching) C++14
0 / 100
1000 ms 348 KB
#define ll long long
#define se second
#define fi first
#define ll long long
#define pb push_back
#define oo 2005
#define pii pair<int,int>
#include <bits/stdc++.h>
using namespace std;
ll n,nho,lon,a[oo];
void sub1()
{
    int i,j,vtm,vtb,tam;

    for(ll w=1;w<=1000000000;w++)
    {

      ll small=w;
      ll big=2*w;
      i=1;
      j=1;
      int anhnho=nho;
      int anhlon=lon;

      vtm=INT_MIN,vtb=INT_MIN;
      while(true)
      {

          if(j>n) break;
          if(i==n&&j==n&&(anhnho>0||anhlon>0))
          {
              cout<<w;
              return;
          }
           tam=a[j]-a[i];

          if(tam<=small)
        {
            vtm=max(vtm,j);
        }
        if(tam<=big&&tam>small)
        {
            vtb=max(vtb,j);
        }
        if(anhlon<0||anhnho<0)
            break;
        if(tam>big)
        {

         if(anhlon>0&&vtb!=INT_MIN)
         {
             i=vtb+1;
             j=vtb;
             anhlon--;

             vtm=INT_MIN,vtb=INT_MIN;
         }
         else
         {
             if(anhnho>0&&vtm!=INT_MIN)
             {
                 i=vtm+1;
                 j=vtm;
                 anhnho--;
                 vtm=INT_MIN,vtb=INT_MIN;
             }
         }
         }

        j++;

      }
    }

}
void enter()
{
    cin>>n>>nho>>lon;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+n);
        sub1();

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("EVENTS.inp","r",stdin);
   // freopen("EVENTS.out","w",stdout);
    enter();
}

# Verdict Execution time Memory Grader output
1 Execution timed out 1014 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -