Help me in solving MAXABC problem

My issue

How to use dp here in this question??

My code

#include <bits/stdc++.h>
using  namespace std;
#define int long long
#define db(x) cout<<#x<<" = "<<x<<"  |  ";
long long md = 1e9 + 7;

int32_t main ( ) {
   ios::sync_with_stdio ( false ); cin.tie ( 0 ); cout.tie ( 0 );

   int t;
   cin >> t;
   while ( t-- ) {




      }

   return 0;
   }

Problem Link: MAXABC Problem - CodeChef