Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<algorithm>

struct str
{
	int a, b, c;
};
int t[200];
str b[200];
str dp1[200];
str dp2[200];
int main(){
	int d, n;
	scanf("%d%d", &d, &n);
	for (int i = 0; i < d; i++)
		scanf("%d", &t[i]);
	for (int i = 0; i < n; i++){
		int a_, b_, c_;
		scanf("%d%d%d", &a_, &b_, &c_);
		b[i].a = a_;
		b[i].b = b_;
		b[i].c = c_;
	}
	int min = 101;
	for (int i = 0; i < n; i++)
		if (b[i].a <= t[0] && t[0] <= b[i].b&&min >=b[i].c)
			min = b[i].c;
	dp1[0].a = 0; dp1[0].b = min;
	for (int i = 1; i < d; i++){
		int max = 0;
		for (int j = 0; j < n; j++){
			if (b[j].a <= t[i] && t[i] <= b[j].b&&abs(dp1[i - 1].b - b[j].c) >= max){
				max = abs(dp1[i - 1].b - b[j].c);
				dp1[i].b = b[j].c;
			}
		}
		dp1[i].a = dp1[i - 1].a + max;
	}
	int max = 0;
	for (int i = 0; i < n; i++)
		if (b[i].a <= t[0] && t[0] <= b[i].b&&min <= b[i].c)
			max = b[i].c;
	dp2[0].a = 0; dp2[0].b = min;
	for (int i = 1; i < d; i++){
		max = 0;
		for (int j = 0; j < n; j++){
			if (b[j].a <= t[i] && t[i] <= b[j].b&&abs(dp2[i - 1].b - b[j].c) >= max){
				max = abs(dp2[i - 1].b - b[j].c);
				dp2[i].b = b[j].c;
			}
		}
		dp2[i].a = dp2[i - 1].a + max;
	}
	printf("%d\n",std::max(dp1[d - 1], dp2[d - 1]));
	return 0;
}

Compiler output:
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = str]':
a.cc:55:24:   required from here
   55 |         printf("%d\n",std::max(dp1[d - 1], dp2[d - 1]));
      |                       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:262:15: error: no match for 'operator<' (operand types are 'const str' and 'const str')
  262 |       if (__a < __b)
      |           ~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1045 |     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algobase.h:262:15: note:   'const str' is not derived from 'const std::pair<_T1, _T2>'
  262 |       if (__a < __b)
      |           ~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  448 |     operator<(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algobase.h:262:15: note:   'const str' is not derived from 'const std::reverse_iterator<_Iterator>'
  262 |       if (__a < __b)
      |           ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  493 |     operator<(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algobase.h:262:15: note:   'const str' is not derived from 'const std::reverse_iterator<_Iterator>'
  262 |       if (__a < __b)
      |           ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1694 |     operator<(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algobase.h:262:15: note:   'const str' is not derived from 'const std::move_iterator<_IteratorL>'
  262 |       if (__a < __b)
      |           ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1760 |     operator<(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algobase.h:262:15: note:   'const str' is not derived from 'const std::move_iterator<_IteratorL>'
  262 |       if (__a < __b)
      |           ~~~~^~~~~