-
Notifications
You must be signed in to change notification settings - Fork 1
/
A.cpp
139 lines (131 loc) · 2.94 KB
/
A.cpp
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 2e18
/***template***/
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dd double
#define scl(n) scanf("%lld",&n)
#define scd(n) scanf("%lf",&n)
#define pi pair<ll,ll>
#define pb push_back
#define mp make_pair
#define uu first
#define vv second
#define FOR(i,n) for(ll i=1;i<=n;i++)
#define LOOP(i,n) for(ll i=0;i<n;i++)
#define FOOR(i,a,b) for(ll i=a;i<=b;i++)
#define LOP(i,a,b) for(ll i=a;i<b;i++)
#define sorted(s) sort(s.begin(),s.end())
#define sortedd(s) sort(s.begin(),s.end(),cmp)
#define reversed(s) reverse(s.begin(),s.end())
#define contains(a,b) (find((a).begin(), (a).end(), (b)) != (a).end())
#define MAXN 100005
#define pii 3.1415926536
#define mod 1000000007
#define eps 0.0000000001
#define inf 1e18
#define INF (1LL<<62)
#define mstt(a,b) memset((a),(b),sizeof (a))
#define sz(x) (ll)x.size()
#define uniquee(x) x.erase(unique(x.begin(), x.end()),x.end())
/****only for priority queue******/
/**struct node
{
ll nod,d;
node(ll a,ll b)
{
nod=a;
d=b;
}
bool operator<(const node &p)const
{
return p.d<d;
}
};**/
ll Set(ll n,ll pos)
{
return n=n|(1LL<<pos);
}
ll reset(ll n,ll pos)
{
return n=n&~(1LL<<pos);
}
bool check(ll n,ll pos)
{
return (bool)(n&(1LL<<pos));
}
ll mul(ll a,ll b)
{
ll c;
c = (a%mod * b%mod)%mod;
return c;
}
ll add(ll a,ll b)
{
ll c;
c = (a%mod + b%mod)%mod;
return c;
}
ll sub(ll a,ll b)
{
ll c;
c = ((a%mod - b%mod)%mod + mod)%mod;
return c;
}
ll power(ll x,ll y)
{
ll res = 1;
x = x;
while (y > 0)
{
if (y & 1)
res = (res*x);
y = y>>1;
x = (x*x);
}
return res;
}
long long exgcd(long long x, long long y, long long &a, long long &b)
{
// ax + by = gcd(x,y)
int flag = 0;
long long t, la = 1, lb = 0, ra = 0, rb = 1;
while(x%y)
{
if(flag == 0)
la -= x/y*ra, lb -= x/y*rb;
else
ra -= x/y*la, rb -= x/y*lb;
t = x, x = y, y = t%y;
flag = 1 - flag;
}
if(flag == 0)
a = ra, b = rb;
else
a = la, b = lb;
return y;
}
/***template***/
int main()
{
ll n, sum = 0;
cin >> n;
ll ara[n + 6];
for(ll i = 0; i < n; i++){
scanf("%lld", &ara[i]);
sum += ara[i];
}
ll tmp = sum / 2;
if(sum % 2 != 0)
tmp++;
sum = 0;
for(ll i = 0; i < n; i++) {
sum += ara[i];
if(sum >= tmp) {
cout << i + 1 << endl;
return 0;
}
}
return 0;
}