Submission #37755

# Submission time Handle Problem Language Result Execution time Memory
37755 2017-12-28T02:24:27 Z MatheusLealV Watching (JOI13_watching) C++14
0 / 100
0 ms 2196 KB
#include <bits/stdc++.h>
#define N 2050
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;

int n, p, q, v[N], barrier[N], ans;

vector<pii> lista;

vector<int> piores;

int32_t main()
{
  ios::sync_with_stdio(false); cin.tie(0);

  cin>>n>>p>>q;

  for(int i = 1; i <= n; i++) cin>>v[i];

  if(p + q >= n)
  {
    cout<<"1\n";

    return 0;
  }

  sort(v + 1, v + n + 1);

  for(int i = 1; i < n; i++) lista.push_back(pii(v[i + 1] - v[i], i));

  sort(lista.rbegin(), lista.rend());

  cout<<"\n";

  for(int i = 1; i <= n; i++) cout<<v[i]<<"\n";

  for(int i = 0; i < p + q - 1; i++)
  {
    int idx = lista[i].s;

    barrier[idx] = 1;

    cout<<"BARREIRA "<<idx<<"\n";
  }

  for(int i = 1; i <= n; i ++)
  {
      int fim = v[i], ini = v[i];

      while(true)
      {
        fim = v[i];

        i++;

        if(i > n || barrier[i - 1] ) break;
      }

      piores.push_back(fim - ini + 1);

      i--;
  }

  sort(piores.rbegin(), piores.rend());

  int dois_w = (piores[0] + 1)/2, w =  piores[q];

  cout<<max(dois_w, w)<<"\n";
  
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2196 KB Execution killed because of forbidden syscall writev (20)
2 Halted 0 ms 0 KB -