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

Previous submission (verdict: Wrong answer on test 2):

#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>

int mod1=998244353;
using namespace std;


long long nChoosek( long long n, long long k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    long long result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}


//long long power(long long a, long long b, long long m){
//    if (b==0) return 1;
//    if (b==1) return a%m;
//    
//    long long temp=power(a,b/2,m)%m;
//    if (b%2) return (temp*temp*a)%m;
//    else return (temp*temp)%m;
//}

long long max(long long a, long long b){
    if (a<b) return b;
    return a;
}

int main(){
    int t,n,x;
    cin>>t;
    
    while (t--){
        cin>>n;
        vector<long long>nos;
        long long ans1=0;
        long long ans2=0;
        for (int i=0; i<n; i++){
            cin>>x;
            nos.push_back(x);
            ans1+=x;
        }
        
        if (n==1){
            cout<<x<<endl;
            continue;
        }
        vector<long long> diffs;
        for (int i=1; i<=n-1; i++){
            for (int i=0; i<nos.size()-1; i++){
                int x=nos[i]-nos[i+1];
                ans2+=x;
                diffs.push_back(x);
            }
            nos=diffs;
            diffs.clear();
//            cout<<nos.size()<<"size"<<diffs.size()<<endl;

            if (abs(ans2)>ans1) ans1=abs(ans2);
            ans2=0;
        }
        
        cout<<ans1<<endl;
    }
}



Submission (verdict: Accepted):

#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>

int mod1=998244353;
using namespace std;


long long nChoosek( long long n, long long k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    long long result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}


//long long power(long long a, long long b, long long m){
//    if (b==0) return 1;
//    if (b==1) return a%m;
//    
//    long long temp=power(a,b/2,m)%m;
//    if (b%2) return (temp*temp*a)%m;
//    else return (temp*temp)%m;
//}

long long max(long long a, long long b){
    if (a<b) return b;
    return a;
}

int main(){
    int t,n,x;
    cin>>t;
    
    while (t--){
        cin>>n;
        vector<long long>nos;
        long long ans1=0;
        long long ans2=0;
        for (int i=0; i<n; i++){
            cin>>x;
            nos.push_back(x);
            ans1+=x;
        }
        
        if (n==1){
            cout<<x<<endl;
            continue;
        }
        vector<long long> diffs;
        for (int i=1; i<=n-1; i++){
            for (int i=0; i<nos.size()-1; i++){
                long long x=nos[i]-nos[i+1];
                ans2+=x;
                diffs.push_back(x);
            }
            nos=diffs;
            diffs.clear();
//            cout<<nos.size()<<"size"<<diffs.size()<<endl;

            if (abs(ans2)>ans1) ans1=abs(ans2);
            ans2=0;
        }
        
        cout<<ans1<<endl;
    }
}