Код: Выделить всё
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int main() {
ifstream fin("exampleinput.txt");
ofstream fout("exampleoutput.txt");
long long tc_num = 0;
long long tc_amount;
fin >> tc_amount;
for(int i = 0; i < tc_amount; i++) {
long long len; fin >> len;
vector height_list(len, -1);
for(int j = 0; j < len; j++) {
fin >> height_list[j];
}
long long max_dif = 0;
sort(height_list.begin(), height_list.end());
vector better_heights(len, -1);
int left = 0;
int right = len - 1;
bool Is_Left = true;
for (int j = 0; j < len; j++) {
if (Is_Left) {
better_heights[left] = height_list[j];
left++;
} else {
better_heights[right] = height_list[j];
right--;
}
Is_Left = !Is_Left;
}
for (int k = 1; k < len; k++) {
max_dif = max(max_dif, better_heights[k] - better_heights[k - 1]);
}
fout
Подробнее здесь: [url]https://stackoverflow.com/questions/79798485/ostream-tcc-is-broken-because-of-an-fstream-problem-c[/url]