#include <iostream>
#include <vector>
#include <cmath>

int main(){
	std::vector<std::vector<double>> Towers{ { 26.4, 46.3, -3.0, 19.8 }, { -20.9, 39.8, 33.2, -4.1 }, { -26.2, -26.7, 26.1, -0.3 }, { -29.2, -12.0, 24.3, 45.1 } };
	std::vector<double> Ghost{ 0.4, 30, 7.8, 19.1 };
	std::vector<std::pair<int,double>> Res;
	double T = 0;

	for (std::size_t i = 0; i < Towers.size(); i++){
		T = 0;
		for (std::size_t j = 0; j < Towers[i].size(); j++){
			T += std::abs(Ghost[j] - Towers[i][j]);
		}
		if (Res.size() == 0){
			Res.push_back(std::make_pair(static_cast<int>(i), T));
			continue;
		}
		if (T < Res[0].second){
			Res.clear();
			Res.push_back(std::make_pair(static_cast<int>(i), T));
			continue;
		}
		if (T == Res[0].second){
			Res.push_back(std::make_pair(static_cast<int>(i), T));
			continue;
		}
	}

	int i = 0;
	std::cout << "in:"<<std::endl;
	for (auto& v : Towers){
		std::cout << static_cast<char>('A' + i++)<<'[';
		for (auto& o : v){
			std::cout << o << ',';
		}
		std::cout << "]"<<std::endl;
	}
	std::cout << std::endl;

	std::cout << "out:";
	for (auto& o : Res) std::cout << static_cast<char>('A' + o.first) << '@' << o.second;
	std::cout << std::endl << std::endl;

	return 0;
}