\section{Implementation}
\label{sec:implementation}

A C implementation accompanies this report. The $\PR$ function is implemented in $\pazocal O(1)$ in \mintinline{c}{round_profit}, but is not shown here for the sake of brevity.

The implementation of the $\PP$ function, \mintinline{c}{maximum_profit}, follows the flow of \autoref{alg:maximum-profit-optimised}. However, it was easier to take the optimisation of \autoref{lem:divide-by-5} out of this function and apply it when reading in the input sequence.

\inputminted[fontsize=\footnotesize,linenos,firstline=17,lastline=48]{c}{../checkout.c}

In the \mintinline{c}{main} function we see how \autoref{lem:divide-by-5} can be applied. In the last line we also see how the minimal sum may be computed from the maximum profit.

\inputminted[fontsize=\footnotesize,linenos,firstline=50,lastline=67]{c}{../checkout.c}

\subsection{Compilation}
\label{sec:implementation:compilation}
Optimal results are achieved with \texttt{clang}, which is on average $25\%$ faster than \texttt{gcc}\footnote{Using \texttt{-Ofast}.}. In any case, the \texttt{-Ofast} flag should be used. It speeds up the program with a factor $4$ in the case of \texttt{clang} and a factor $3$ in the case of \texttt{gcc}.

A Makefile accompanies the C code. If you don't have \texttt{clang} installed, you should install it. If you don't want to install it, use \mintinline{bash}{make CC=gcc}.

