lanzamientoFornite

Zaid · December 31, 2020 · C++
#include <iostream>
#include <cmath>
using namespace std;

int main() {
  int N,X,Y;
  float d1=0,d2=0;
  string p="",g="";
  cin>>N;
  if (N < 2 || N > 4)
    return 0;
  cin>>p;
  cin>>X>>Y;
  d1 = sqrt(pow(X,2)+pow(Y,2));
  cin>>X>>Y;
  d1 += sqrt(pow(X,2)+pow(Y,2));
  g = p;
  N--;
  while (N > 0) {
    cin>>p;
    cin>>X>>Y;
    d2 = sqrt(pow(X,2)+pow(Y,2));
    cin>>X>>Y;
    d2 += sqrt(pow(X,2)+pow(Y,2));
    if (d1 < d2) {
      g = p;
    } else if (d1 == d2) {
      g += "\n" + p;
    }
    d1 = d2;
    N--;
  }
  cout<<g<<endl;
  return 0;
}

Comments

Please sign up or log in to contribute to the discussion.