#include <bits/stdc++.h>
using namespace std;
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,sse4a,abm,mmx,avx,avx2,fma,popcnt,tune=native")
#define int long long
#define qweqdasd ios_base::sync_with_stdio(0), cin.tie(0)
#define pb push_back
#define st first
#define nd second
#define watch(x) (cout << #x << " == " << x << '\n')
mt19937_64 rng(147098291);
random_device rd;
mt19937_64 mersenne(rd());
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
const int mod2 = (119 << 23) + 1; // 998244353
const int inf = 1e18;
const double eps = 1e-7;
const int block = 350;
const int dx[] = { -1, 1, 0, 0, -1, -1, 1, 1 };
const int dy[] = { 0, 0, -1, 1, -1, 1, -1, 1 };
int a[maxn];
void solve()
{
int n;
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
int rs = 1;
int i = 2;
while (i <= n) {
if (a[i] >= a[i - 1]) {
rs++;
i++;
} else {
int zxc = a[i];
bool mark = false;
for (int j = i + 1; j <= n; ++j) {
zxc += a[j];
if (zxc >= a[i - 1]) {
rs++;
i = j + 1;
mark = true;
break;
}
}
if (!mark) {
i = n + 1;
}
}
}
cout << rs;
}
int32_t main()
{
qweqdasd;
int tests = 1;
// cin >> tests;
for (int i = 1; i <= tests; ++i) {
// cout << "Case " << i << ":\n";
solve();
}
#ifdef LOCAL
cerr << '\n'
<< "fnshd in " << clock() * 1.0 / CLOCKS_PER_SEC << " s\n";
#endif
}
/**
*
*/
# | 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... |