제출 #677688

#제출 시각아이디문제언어결과실행 시간메모리
677688mjhmjh1104Seesaw (JOI22_seesaw)C++17
1 / 100
72 ms264 KiB
#include <cstdio>
#include <numeric>
#include <algorithm>
using namespace std;

int n, a[200006];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", a + i);
    double res = 1 / 0.;
    for (int i = 0; i < 1 << n; i++) {
        int l = 0, r = n - 1;
        long long sum = accumulate(a, a + n, 0LL);
        int cnt = n;
        double curr = sum / (double)cnt;
        double mx = curr, mn = curr;
        for (int j = 0; j < n; j++) {
            if (i & 1 << j) sum -= a[l++];
            else sum -= a[r--];
            cnt--;
            curr = sum / (double)cnt;
            mx = max(mx, curr);
            mn = min(mn, curr);
        }
        res = min(res, mx - mn);
    }
    printf("%.10f", res);
}

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

seesaw.cpp: In function 'int main()':
seesaw.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
seesaw.cpp:10:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for (int i = 0; i < n; i++) 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...