Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
int const N = 2e5 + 1;
int n, a[N];
int main() {
scanf("%d", &n);
for(int i = 0; i < 2 * n; ++i)
scanf("%d", a + i);
sort(a, a + 2 * n);
long long res = 1ll * (a[n - 1] - a[0]) * (a[2 * n - 1] - a[n]);
for(int i = 1, j = n; i < n; ++i, ++j)
res = min(res, 1ll * (a[2 * n - 1] - a[0]) * (a[j] - a[i]));
printf("%lld\n", res);
return 0;
}
Copy The Code &
Try With Live Editor
Input
4
4 1 3 2 3 2 1 3
4 1 3 2 3 2 1 3
Output
1
Demonstration
Codeforces Solution-C. Photo of The Sky-Solution in C, C++, Java, Python,Photo of The Sky,Codeforces Solution