wojiaocbj

Untitled

May 21st, 2022
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #pragma warning(disable:4996)
  7. typedef long long s64, LL;
  8. typedef unsigned long long u64, ULL;
  9. typedef const void *cvp;
  10. #define MAX(a,b) (((a)>(b))?(a):(b))
  11. int cmpi32(const void *p, const void *q){
  12.     int a = *((int *)p), b = *((int *)q);
  13.     if(a > b)return 1;
  14.     else if(a < b)return -1;
  15.     else return 0;
  16. }
  17. int arr[1919810] = { 0 };
  18. int main(){
  19. #ifdef _DEBUG
  20.     FILE *fp = freopen("../../../input.txt", "r", stdin);
  21.     //FILE *fp2 = freopen("../../../output.txt", "w", stdout);
  22. #endif // _DEBUG
  23.     int n, m, i, t;
  24.     scanf("%d%d", &n, &m);
  25.     for(i = 0; i < m; i++){
  26.         scanf("%d", arr + i);
  27.     }
  28.     qsort(arr, m, sizeof(int), cmpi32);
  29.     t = MAX(arr[0] - 1, n - arr[m - 1]);
  30.     for(i = 1; i < m; i++){
  31.         t = MAX(t, (arr[i] - arr[i - 1]) / 2);
  32.     }
  33.     printf("%d\n", t + 1);
  34. #ifdef _DEBUG
  35.     fp = freopen("CON", "r", stdin);
  36.     //fp2 = freopen("CON", "w", stdout);
  37.     system("pause");
  38. #endif // _DEBUG
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment