Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
/* 
    Author : Hossain Ahmed Siam
    Date   : 2025-02-02
    Time   : 15:36:30
*/


#include<bits/stdc++.h>
using namespace std;

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ld long double
#define int64 int64_t

#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long>

#define fill_arr(x) for(auto &n:x) {cin>> n;}

#define all(vec) begin(vec), end(vec)
#define pb push_back
#define fi first
#define se second

#define MOD 1000000007
#define INF 1e9
#define nline "\n"
#define  print(x) cout<<x<<"\n"

#define debugCode(x) cout<<"Debug : "<< x<< nline;

ll solve(int n, vll& nums,ll dp[]){
    
    if(n == 1) return nums[0];
    if(dp[n]) return dp[n];
    ll ans = LLONG_MIN;
    
    ll sum1 = 0;
   
    for(auto num: nums) sum1 += num;
    reverse(all(nums));
   

    ans =  max({ans, sum1});
    
    vll temp;
    
    for(int i =0; i< n-1; i++){
        
        temp.pb(nums[i+1] - nums[i]);

    }

    ll left = solve(n-1, temp, dp);
    
    reverse(all(nums));
    
    vll temp2 ;
    for(int i = 0; i< n-1; i++){
        temp2.pb(nums[i+1]- nums[i]);
    }

    ll right = solve(n-1, temp2,dp);

    return dp[n] = max({ans, left , right}) ;

    


}





int main() {

    fast_io;

    int t;
    cin>>t;

    while(t--){
        
        int n ;
        cin>>n;
        
        vll nums(n);
        fill_arr(nums);
        ll dp[51] = {0};
        
        ll ans =solve(n, nums, dp); 
        print(ans);

    }
    return 0;
}









Submission (verdict: Wrong answer on test 2):
/* 
    Author : Hossain Ahmed Siam
    Date   : 2025-02-02
    Time   : 15:36:30
*/


#include<bits/stdc++.h>
using namespace std;

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ld long double
#define int64 int64_t

#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long>

#define fill_arr(x) for(auto &n:x) {cin>> n;}

#define all(vec) begin(vec), end(vec)
#define pb push_back
#define fi first
#define se second

#define MOD 1000000007
#define INF 1e9
#define nline "\n"
#define  print(x) cout<<x<<"\n"

#define debugCode(x) cout<<"Debug : "<< x<< nline;

ll solve(int n, vll& nums,ll dp[]){
    
    if(n == 1) return nums[0];
    if(dp[n]) return dp[n];
    ll ans = LLONG_MIN;
    
    ll sum1 = 0;
   
    for(auto num: nums) sum1 += num;

    ans =  max({ans, sum1});
    
    vll temp;
    
    for(int i =0; i< n-1; i++){
        
        temp.pb(nums[i+1] - nums[i]);

    }

    ll left = solve(n-1, temp, dp);
    
    reverse(all(nums));
    
    vll temp2 ;
    for(int i = 0; i< n-1; i++){
        temp2.pb(nums[i+1]- nums[i]);
    }

    ll right = solve(n-1, temp2,dp);

    return dp[n] = max({ans, left , right}) ;

    


}





int main() {

    fast_io;

    int t;
    cin>>t;

    while(t--){
        
        int n ;
        cin>>n;
        
        vll nums(n);
        fill_arr(nums);
        ll dp[51] = {0};
        
        ll ans =solve(n, nums, dp); 
        print(ans);

    }
    return 0;
}