#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#include <numeric>
#include <numbers>
#include <cmath>
#include <algorithm>
#include <array>
#include <unordered_map>
//#define TEST
using namespace std;
stringstream ss;
int toler = 4;
vector<double> estimate(vector<double>::iterator first, vector<double>::iterator last)
{
vector<double> output;
output.resize(12, -1000);
double lv = *(last - 1);
for (int i = 0; auto & e : output)
{
if (i++ < toler)
{
e = lv;
}
else if (*max_element(first, last) - *min_element(first, last) < 3 && i < 13)
e = lv;
else if (*max_element(first, last) - *min_element(first, last) < 5 && i < 8)
e = lv;
else if (*max_element(first, last) - *min_element(first, last) < 6 && i < 6)
e = lv;
}
return output;
}
int main()
{
int n;
#ifdef TEST
fstream f;
f.open(__FILE__ "/../../sample-data.txt");
f >> n;
n = 8000;
int a = 0, b = 0;
double bestScore = 0;
double tl = 0;
for (int i = 0; i < n; i++)
{
vector<double> dt;
for (int j = 0; j < 36; j++)
{
double v;
f >> v;
dt.push_back(v);
}
auto res = estimate(dt.begin(), dt.begin() + 24);
// Compare results
//cout << i + 2 << ": ";
for (int i = 0; i < 12; i++)
{
if (res[i] != -1000.0)
{
double dif = abs(res[i] - dt[i + 24]);
if (dif < 0.75)
{
//cout << "C ";
a++;
}
else if (dif > 2.05)
{
//cout << res[i] - dt[i + 24] << " ";
b++;
}
else
{
//cout << ". ";
}
}
}
//cout << "\n";
}
cout << "Value for tolerance: " << tl << "\n";
cout << "Estimate results: (a: " << a << "), (b: " << b << ")\n";
cout << "Final score: " << max(0.0, (25.0 * (a - b)) / ((double)n));
f.close();
#else
cin >> n;
for (int i = 0; i < n; i++)
{
vector<double> dt;
for (int j = 0; j < 24; j++)
{
double v;
cin >> v;
dt.push_back(v);
}
auto res = estimate(dt.begin(), dt.end());
for (auto r : res)
{
if (r != -1000)
ss << r << " ";
else
ss << "? ";
}
ss << "\n";
}
cout << ss.str();
#endif
return 0;
}