Submission #1127874

#TimeUsernameProblemLanguageResultExecution timeMemory
1127874sleepntsheepRoom Temperature (JOI24_ho_t1)C11
100 / 100
178 ms6064 KiB
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>

int compar(const void *i, const void *j)
{
  return *(int*)i - *(int*)j;
}

int main()
{
  int n, t, i, min, range, k;
  static int a[1 << 20];

  range = INT_MAX;

  scanf("%d%d", &n, &t);
  for (i = 0; i < n; ++i)
  {
    scanf("%d", a + i);
    a[i + n] = a[i] % t + t;
    a[i]     = a[i] % t;
  }

  qsort(a, 2 * n, sizeof *a, compar);

  for (i = 0; i < n; ++i)
  {
    if (range > (k = a[i + n - 1] - a[i]))
    {
      range = k;
    }
  }

  printf("%d\n", (range + 1) / 2);

  return 0;
}

Compilation message (stderr)

Main.c: In function 'main':
Main.c:17:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d%d", &n, &t);
      |   ^~~~~~~~~~~~~~~~~~~~~
Main.c:20:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d", a + i);
      |     ^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...