#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
// #pragma GCC target("avx2")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
//-------------------------------------------------------------------------------------------------------------
#define int long long
#define pb push_back
#define ew "\n"
#define all(x) (x).begin(), (x).end()
#define st first
#define nd second
#define len(x) (int)x.size()
#define eb emplace_back
#define turbo \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
const int maxn = 2e5 + 12;
const int mxx = 100100;
const int MOD = 1e9 + 7;
const int inf = 1e18 + 7;
const int HH = 1e2 + 70;
int n;
int a[maxn], pref[maxn];
void code()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
pref[i] = pref[i - 1] + a[i];
}
int rs = 0;
for (int i = 1; i <= n; i++)
{
int lst = pref[i], cur = 0, ans = 1;
for (int j = i + 1; j <= n; j++)
{
cur += a[j];
if (cur >= lst && cur <= a[j + 1] && j + 1 <= n)
{
lst = cur;
cur = 0;
ans++;
}
if (j == n)
{
if (cur >= lst)
{
ans++;
}
}
}
rs = max(rs, ans);
}
cout << rs;
}
int32_t main()
{
// freopen("248.in", "r", stdin);
// freopen("248.out", "w", stdout);
// turbo;
int tt = 1, j = 1;
// cin >> tt;
while (tt--)
{
// cout << "Case " << j << ":" << ew;
code();
// j++;
}
}
// by sl1pzz
// going to respa silver/goldz
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |