Datasets:

Modalities:
Image
Text
Formats:
parquet
Size:
< 1K
Tags:
code
Libraries:
Datasets
pandas
License:
hackercup / 2023 /round1 /here_comes_santa_claus.cpp
wjomlex's picture
2023 Problems
ff444f7 verified
raw
history blame contribute delete
595 Bytes
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
double solve() {
int N;
cin >> N;
vector<int> X(N);
for (int i = 0; i < N; i++) {
cin >> X[i];
}
sort(X.begin(), X.end());
double ans = X[N-1] + X[N-2] - (X[0] + X[1]);
if (N == 5) {
ans = max(
X[N-1] + X[N-3] - (X[0] + X[1]),
X[N-1] + X[N-2] - (X[0] + X[2])
);
}
return ans / 2;
}
int main() {
int T;
cin >> T;
cout.precision(1);
for (int t = 1; t <= T; t++) {
cout << "Case #" << t << ": " << fixed << solve() << endl;
}
return 0;
}