codeforce#500 C. Photo of The Sky

地址:http://codeforces.com/contest/1013/problem/C
思维总是不能全面的想,只想到了找矩形的左下和右上点,但也可以找左上和右下的点,这点就没想到,本来是个简单题。。。。

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int inf = 0x3f3f3f3f;
const int N = 200005;
int a[N];

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i = 0;i < 2 * n;++i)
        {
            scanf("%d",&a[i]);
        }
        sort(a,a + 2 * n);
        LL ans = 1LL * (a[n - 1] - a[0]) * (a[2 * n - 1] - a[n]);
        for(int i = 1;i < n;++i)
        {
            ans = min(ans,1LL * (a[n + i - 1] - a[i]) * (a[2 * n - 1] - a[0]));
        }
        printf("%lld\n",ans);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_36386435/article/details/81293831
sky