Pagini recente » Cod sursa (job #109448) | Cod sursa (job #3235044) | Cod sursa (job #2465715) | Cod sursa (job #1987026) | Cod sursa (job #1366209)
#include <fstream>
#include <algorithm>
#include <iomanip>
using namespace std;
ifstream in("popandai.in");
ofstream out("popandai.out");
struct punct{
int x, y;
};
const int nmax = 306, inf = 1000000000;
int n, k, sol, d[nmax][nmax];
double sus[nmax], jos[nmax], rasp;
punct v[nmax];
bool compar (punct a, punct b)
{
if(a.x!=b.x)
return a.x<b.x;
else
return a.y<b.y;
}
int det(int i, int j, int k)
{
return 1LL*(v[j].x-v[i].x)*(v[k].y-v[i].y) - 1LL*(v[k].x-v[i].x)*(v[j].y-v[i].y);
}
int main(){
int player_unu=0;
out<<setprecision(1)<<fixed;
in>>n>>k;
for(int i = 1; i<=n; i++)
in>>v[i].x>>v[i].y;
sort(v + 1, v + n + 1, compar);
for(int i = 1; i<n; i++)
{
for(int j = i + 1; j<n; j++)
{
for(int h = j + 1; h<=n; h++)
if (det(i, h, j)<0)
{
d[i][h]++;
d[h][i]++;
}
}
}
rasp = inf;
for (int i = 1; i<n; i++)
{
for (int j = i + 1; j<=n; j++)
{
for (int h = 0; h<=n; h++)
sus[h] = jos[h] = inf;
for (int h = 1; h<=n; h++) {
if (i==h || j==h)
continue;
int a = min(min(i, j), h);
int c = max(max(i, j), h);
int b = i;
if (b==a||b==c) {
b = j;
if (b==a||b==c)
b = h;
}
sol = d[a][b] + d[b][c] - d[a][c];
if (det(i, j, h)>0)
sus[sol] = min(sus[sol], 1.0 * det(i, j, h) / 2.0);
else
jos[sol] = min(jos[sol], -1.0 * det(i, j, h) / 2.0);
}
for(int h = n - 1; h>=0; h--)
{
sus[h] = min(sus[h], sus[h + 1]);
jos[h] = min(jos[h], sus[h + 1]);
}
for (int h = 0; h<=k; h++)
rasp = min(rasp, sus[k] + jos[k-h]);
}
}
out<<rasp<<"\n";
return 0;
}