Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
 
/*                                             सम्भवामि युगे युगे ॥                                      */

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define inf std::numeric_limits<int>::max();
#define yup cout<<"YES"<<endl;
#define nope cout<<"NO"<<endl;
const int MOD = 1e9+7;
ll binaryExpo(ll base, ll e)
{
    ll res=1;
    while (e)
    {
        if(e&1) (res *= base)%=MOD;
        (base *= base)%=MOD; e/=2;
    } return res;
}

void solutioN()
{
    ll n; cin>> n;
    vector<ll> v(n), anotherV;
    ll sum = 0;
    for(int i=0; i<n; i++)
    {
        cin>> v[i];
        anotherV.push_back(v[i]);
        sum += v[i];
    }


    while ((anotherV.size())>1)
    {
        vector<ll> chkSorted;
        chkSorted = anotherV;
        sort(chkSorted.begin(),chkSorted.end());

        if(chkSorted!=anotherV) reverse(anotherV.begin(),anotherV.end());

        vector<ll> tempV;
        for(int i=1; i<anotherV.size(); i++)
        {
            tempV.push_back(anotherV[i]-anotherV[i-1]);
        }

        anotherV.clear();
        anotherV = tempV;
        ll ss = accumulate(tempV.begin(),tempV.end(),0);
        sum = max(sum, ss);
    }
    cout<< sum <<endl;
}

void solve_mul()
{ ll test; cin>>test; while (test--) {solutioN();} }

void solve_single(){solutioN();}

int main()
{
    ios_base::sync_with_stdio(false);
    solve_mul();
    //solve_single();
}






/*                                Ⓒ All rights reserved to Prnc                              */

Submission (verdict: Wrong answer on test 2):
 
/*                                             सम्भवामि युगे युगे ॥                                      */

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define inf std::numeric_limits<int>::max();
#define yup cout<<"YES"<<endl;
#define nope cout<<"NO"<<endl;
const int MOD = 1e9+7;
ll binaryExpo(ll base, ll e)
{
    ll res=1;
    while (e)
    {
        if(e&1) (res *= base)%=MOD;
        (base *= base)%=MOD; e/=2;
    } return res;
}

void solutioN()
{
    ll n; cin>> n;
    vector<ll> v(n), anotherV;
    ll sum = 0;
    for(int i=0; i<n; i++)
    {
        cin>> v[i];
        anotherV.push_back(v[i]);
        sum += v[i];
    }


    while ((anotherV.size())>=1)
    {
        ll ss = accumulate(anotherV.begin(),anotherV.end(),0);
        sum = max(sum, ss);

        for(int i=1; i<anotherV.size(); i++)
        {
            if(anotherV[i]<anotherV[i-1])
            {
                reverse(anotherV.begin(),anotherV.end());
                break;
            }
        }


        vector<ll> tempV;
        for(int i=1; i<anotherV.size(); i++)
        {
            tempV.push_back(anotherV[i]-anotherV[i-1]);
        }
        anotherV.clear();
        anotherV = tempV;
    }
    cout<< sum <<endl;
}

void solve_mul()
{ ll test; cin>>test; while (test--) {solutioN();} }

void solve_single(){solutioN();}

int main()
{
    ios_base::sync_with_stdio(false);
    solve_mul();
    //solve_single();
}






/*                                Ⓒ All rights reserved to Prnc                              */