Language: C++

#include <iostream>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include <algorithm>
#include<string.h>
#define ll long long
#define ull unsigned long long
using namespace std;
/* 
struct edge{
	int to, nxt;
}e[100005];
int head[100005], tot = 1, x, num[100005];
void add(int v, int u)
{
	e[tot].to = u, e[tot].nxt = head[v], head[v] = tot++;
}*/ 
ll ans;
int n, k, r, s, p, gt[] = {2, 0, 1}, sc[3];
ll a[100005][3];
char tr[100005]; 
signed main() 
{
	while (~scanf("%d%d%d%d%d", &n, &k, &sc[0], &sc[1], &sc[2]))
	{
		scanf("%s", tr);
		for (int i = 0; i < n; i++)
			if (tr[i] == 'r')	tr[i] = 0;
			else if (tr[i] == 's') tr[i] = 1;
			else tr[i] = 2;
		ans = 0;
		for (int i = 0; i < n; i++)
		{
				for (int j = 0; j < 3; j++)
				{
					int tp = 0;
					if (i >= k)
					for (int l = 0; l < 3; l++)
					{
						if (j != l)
						{
							tp = max(a[i - k][l], tp);
						}
					}
					if (j == tr[i])
						a[i][j] = 0;
					else if (j == gt[tr[i]])
						a[i][j] = sc[j];
					else
						a[i][j] = -sc[tr[i]];
					a[i][j] += tp;
				}
			}
		for (int i = n - 1; i > n - 1 - k; i--)
		{
			int tp = 0;
			for (int j = 0; j < 3; j++)
				tp = max(a[i][j], tp);
			ans += tp;
		}
		printf("%lld\n", ans);
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:65: error: no matching function for call to 'max(long long int&, int&)'
   46 |                                                         tp = max(a[i - k][l], tp);
      |                                                              ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:46:65: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   46 |                                                         tp = max(a[i - k][l], tp);
      |                                                              ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:46:65: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   46 |                                                         tp = max(a[i - k][l], tp);
      |                                                              ~~~^~~~~~~~~~~~~~~~~
a.cc:62:41: error: no matching function for call to 'max(long long int&, int&)'
   62 |                                 tp = max(a[i][j], tp);
      |                                      ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:62:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   62 |                                 tp = max(a[i][j], tp);
      |                                      ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:62:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   62 |                                 tp = max(a[i][j], tp);
      |                                      ~~~^~~~~~~~~~~~~