Cod sursa(job #2931540)

Utilizator smunteanuMunteanu Stefan Catalin smunteanu Data 31 octombrie 2022 12:59:52
Problema Rubarba Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.11 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 = INFINITY;
  double mxx = -INFINITY;
  double mny = INFINITY;
  double mxy = -INFINITY;
  for (int i = 0; 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 deg = 0; deg < 180; deg += pow(0.5, 4)) {
    const double ang = M_PI * deg / 180.0;
    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;
  



}