CSES - Datatähti 2021 alku - Results
Submission details
Task:Alitaulukot
Sender:_Ahrou
Submission time:2020-10-02 14:03:43 +0300
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status

Code

#include <iostream>
#include <vector>
#include <algorithm>

int get_sub_tables(int* p_table, int size, int differece)
{
	int n_sub_tables = 0;
	for (auto left_i = p_table; left_i != p_table + size; ++left_i)
	{
		n_sub_tables++;
		int min = *left_i;
		int max = *left_i;
		int n_digits = 1;
		for (auto right_i = left_i + 1; right_i != p_table + size; )
		{
			if (*right_i > max)
				max = *right_i;
			else if (*right_i < min)
				min = *right_i;
			int d = max - min;
			if (d <= differece)
			{
				if (right_i - left_i >= n_digits)
				{
					n_sub_tables++;
					n_digits++;
					right_i = left_i + 1;
					min = *left_i;
					max = *left_i;
					continue;
				}
				else
					++right_i;
			}
			else
				break;
		}
	}
	return n_sub_tables;
}

//int main()
//{
//	int n;
//	int difference;
//	int table[100000];
//	std::cin >> n;
//	std::cin >> difference;
//	for (int i = 0; i < n; i++)
//	{
//		std::cin >> table[i];
//	}
//	std::cout << get_sub_tables(table, n, difference);
//	return 0;
//}