Thursday 24 August 2017

Equilibrium point

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
///     Raihan Ruhin (username: raihanruhin)
///     Resume: https://raihanruhin.github.io

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

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define PI acos(-1.0)

#define MOD 1000000007
#define MX 100010

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0);

    int tc, kk=1, n, x, consecutive_sum[102];
    bool found;
    consecutive_sum[0]=0;
    cin>>tc;

    while(tc--)
    {
        found =false;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>x;
            consecutive_sum[i] = consecutive_sum[i-1] + x;
        }
        for(int i=1;i<=n;i++)
        {
            if(consecutive_sum[n]-consecutive_sum[i] == consecutive_sum[i-1])
            {
                found =true;
                cout<<i<<endl;
                break;
            }
        }
        if(!found)
            cout<<-1<<endl;
        //cout<<"Case "<<kk++<<": "<< <<"\n";
    }
    return 0;
}

1 comment:

  1. The actual laptops are available in ignore, layered, plus dot-grid pages of content, a final that have access to a operation akin to Doane�s grid papers (including a bit less complicated for the big eyes, in case in which makes a difference back). https://imgur.com/a/OIOedQ8 http://j4c42jd2go.dip.jp https://imgur.com/a/RAscOUV http://2pychwqv7y.dip.jp https://imgur.com/a/ncXa7rw https://imgur.com/a/Lr9uyXO http://534efp319o.dip.jp

    ReplyDelete