Cod sursa(job #2931543)

Utilizator smunteanuMunteanu Stefan Catalin smunteanu Data 31 octombrie 2022 13:06:49
Problema Rubarba Scor 30
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.05 kb
#include <bits/stdc++.h>
using namespace std;

const int nmax = 1e5 + 7;

static int n;
static int a[nmax][2];
static double p[nmax][2];

double solve() {
  double mnx, mxx, mny, mxy;
  mnx = mxx = p[0][0];
  mny = mxy = p[0][1];
  for (int i = 1; i < n; i++) {
    mnx = min(mnx, p[i][0]);
    mxx = max(mxx, p[i][0]);
    mny = min(mny, p[i][1]);
    mxy = max(mxy, p[i][1]);
  }
  return (mxx - mnx) * (mxy - mny);
}

int main() {

  #ifdef LOCAL
  freopen("file.in", "r", stdin);
  #else
  freopen("rubarba.in", "r", stdin);
  freopen("rubarba.out", "w", stdout);
  #endif

  ios_base::sync_with_stdio(false), cin.tie(NULL);

  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1];

  double ans = INFINITY;
  for (double ang = 0; ang < M_PI * 2.0; ang += 0.0625) {
    for (int i = 0; i < n; i++) {
      p[i][0] = a[i][0] * cos(ang) - a[i][1] * sin(ang);
      p[i][1] = a[i][1] * cos(ang) + a[i][0] * sin(ang);
    }
    ans = min(ans, solve());
  }

  cout << setprecision(2) << fixed << ans;
  



}