Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: loop

Problemset: RANGEandMEAN

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-10 18:32:31

#include <cstdio>

// Values can be larger than a 32-bit long, so use long long; the mean is printed exactly (half rounds away from zero).
int main() {
    int n;
    scanf("%d", &n);
    long long sum = 0, mx = 0, mn = 0;
    for (int i = 0; i < n; i++) {
        long long x;
        scanf("%lld", &x);
        sum += x;
        if (i == 0 || x > mx) mx = x;
        if (i == 0 || x < mn) mn = x;
    }
    long long num = sum * 100;
    bool negative = num < 0;
    if (negative) num = -num;
    long long cents = (num * 2 + n) / (2LL * n);
    if (negative && cents > 0) printf("%lld -%lld.%02lld\n", mx - mn, cents / 100, cents % 100);
    else printf("%lld %lld.%02lld\n", mx - mn, cents / 100, cents % 100);
    return 0;
}