제출 #739886

#제출 시각아이디문제언어결과실행 시간메모리
739886finn__Seesaw (JOI22_seesaw)C++17
100 / 100
59 ms10016 KiB
#include <stdio.h> #include <stdint.h> #include <inttypes.h> #include <stdlib.h> #define N 200001 int64_t a[N]; double e[N][2]; static inline int compare_centers(void const *const u, void const *const v) { return *(double *)u < *(double *)v ? -1 : 1; } int main() { size_t n; scanf("%zu", &n); for (size_t i = 1; i <= n; ++i) scanf("%" PRId64, a + i), a[i] += a[i - 1]; for (size_t k = 0; k < n - 1; ++k) { size_t u = 1, v = n - k; double const y = (double)(k + 1) / n; while (u < v) { size_t const mid = (u + v) / 2; if ((a[mid + k] - a[mid - 1]) < (double)a[n] * y) u = mid + 1; else v = mid; } e[k][0] = (double)(a[u + k] - a[u - 1]) / (k + 1); e[k][1] = (double)(a[u + k - 1] - a[u - 2]) / (k + 1); } e[n - 1][0] = e[n - 1][1] = (double)a[n] / n; qsort(e, n, sizeof *e, compare_centers); double ans = 1e9, minl = (double)a[n] / n; for (size_t i = n - 1; i < n; --i) { ans = e[i][0] - minl < ans ? e[i][0] - minl : ans; minl = e[i][1] < minl ? e[i][1] : minl; } printf("%.10lf\n", ans); }

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

seesaw.cpp: In function 'int main()':
seesaw.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%zu", &n);
      |     ~~~~~^~~~~~~~~~~
seesaw.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%" PRId64, a + i), a[i] += a[i - 1];
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...