这么小的数据范围。暴力啊。不幸的是。暴力都写错了。。。写的O(n2)的,看了下别人的代码,大都是O(n3)的,最无耻的是题解,竟然是O(n^5)
数据范围小也不能这样啊
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int MAXN = 102;
LL x[MAXN],y[MAXN];
vector<LL> vx,vy;
int n,K;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> K;
for(int i = 0; i < n; ++i)
{
cin >> x[i] >> y[i];
vx.push_back(x[i]);
vy.push_back(y[i]);
}
sort(vx.begin(),vx.end());
sort(vy.begin(),vy.end());
LL res = 1LL<<62;
for(int i = 0; i < vx.size(); ++i)
{
for(int j = i+1; j < vx.size(); ++j)
{
vector<LL> vz;
for(int k = 0; k < n; ++k)
if(x[k] >= vx[i] && x[k] <= vx[j])
vz.push_back(y[k]);
sort(vz.begin(),vz.end());
for(int k = 0; k <= (LL)vz.size()-K; ++k)
res = min(res,(vx[j]-vx[i])*(vz[k+K-1]-vz[k]));
}
}
cout << res <<endl;
return 0;
}