답안 #810402

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
810402 2023-08-06T09:16:20 Z caganyanmaz Seesaw (JOI22_seesaw) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>

#define int int64_t
using namespace std;

constexpr static int INF = 3e14;
constexpr static double EPSILON = 0.000000000001;

constexpr static int MXSIZE = 200000;
int a[MXSIZE];

int32_t main()
{
        int n;
        cin >> n;
        for (int i = 0; i < n; i++)
                cin >> a[i];
        int sum = 0;
        for (int i = 0; i < n; i++)
                sum += a[i];

        int la = sum, lb = n, ra = sum, rb = n;

        int step = 0;
        for (int l=0,r=n;r>l;step^=1)
        {
                if (step&1)
                {
                        sum -= a[l++];
                        if (ra * (r-l) < sum * rb)
                        {
                                ra = sum;
                                rb = r-l;
                        }
                }
                else
                {
                        sum -= a[--r];
                        if (la * (r-l) > sum * lb)
                        {
                                la = sum;
                                lb = r-l;
                        }
                }
        }
        double right = static_cast<double>(ra) / rb;
        double left = static_cast<double>(la) / lb;
        cout << fixed;
        cout << setprecision(15);
        cout << (right - left + EPSILON) <<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -