#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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8Y21hdGg+CgppbnQgbWFpbigpewoJc3RkOjp2ZWN0b3I8c3RkOjp2ZWN0b3I8ZG91YmxlPj4gVG93ZXJzeyB7IDI2LjQsIDQ2LjMsIC0zLjAsIDE5LjggfSwgeyAtMjAuOSwgMzkuOCwgMzMuMiwgLTQuMSB9LCB7IC0yNi4yLCAtMjYuNywgMjYuMSwgLTAuMyB9LCB7IC0yOS4yLCAtMTIuMCwgMjQuMywgNDUuMSB9IH07CglzdGQ6OnZlY3Rvcjxkb3VibGU+IEdob3N0eyAwLjQsIDMwLCA3LjgsIDE5LjEgfTsKCXN0ZDo6dmVjdG9yPHN0ZDo6cGFpcjxpbnQsZG91YmxlP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