제출 #1127866

#제출 시각아이디문제언어결과실행 시간메모리
1127866sleepntsheepRoom Temperature (JOI24_ho_t1)C11
35 / 100
1 ms328 KiB
#include <stdio.h> #include <limits.h> #include <stdlib.h> int compar(const void *i, const void *j) { return *(int*)i - *(int*)j; } void *ptr; int compar_(const void *i, const void *j) { int *a; a = ptr; return a[*(int*)i] - a[*(int*)j]; } void chmin(int *a, int b) { if (b < *a) { *a = b; } } int main() { int n, t, i, min, range; static int a[1 << 19], b[1 << 19], c[1 << 19]; range = INT_MAX; scanf("%d%d", &n, &t); for (i = 0; i < n; ++i) { scanf("%d", a + i); c[i] = a[i] % t; b[i] = i; if (min > a[i]) { min = a[i]; } } ptr = c; qsort(b, n, sizeof *b, compar_); for (i = 0; i < n; ++i) { if (c[b[i]] <= min) { if (i) { chmin(&range, t + c[b[i - 1]] - c[b[i]]); } else { chmin(&range, c[b[n - 1]] - c[b[0]]); } } } printf("%d\n", (range + 1) / 2); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.c: In function 'main':
Main.c:34:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |   scanf("%d%d", &n, &t);
      |   ^~~~~~~~~~~~~~~~~~~~~
Main.c:37:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     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...