1 solutions

  • 0
    @ 2026-11-14 11:36:55

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int a[10005],b[10005];
    //1 2 3 4  5
    //1 3 6 10 15
    void solve(){
        int n;
        cin >> n;
        for (int i = 1;i<=n;i++){
            cin >> a[i];
            b[i] = b[i-1] + a[i];
        }       
        for (int i = 1;i<=n;i++){
            int l = b[i];
            int r = b[n] - l;
            if (l == r) {
                cout << "Yes" << endl;
                return;
            }
        }    
        cout << "No" << endl;      
    }
    
    int main(){
        int n;
        cin >> n;
        while(n--){
            solve();
        }
        return 0;
    }
    
    • 1

    Information

    ID
    148
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    2
    Accepted
    2
    Uploaded By