# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
558538 | Tien_Noob | Bigger segments (IZhO19_segments) | C++17 | 77 ms | 13068 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Make CSP great again
//Vengeance
#include <bits/stdc++.h>
#define TASK "TESTCODE"
#define Log2(x) 31 - __builtin_clz(x)
using namespace std;
const int N = 1e6;
long long a[N + 1];
int n, dp[N + 1], pre[N + 1];
void read()
{
cin >> n;
for (int i = 1; i <= n; ++ i)
{
cin >> a[i];
a[i] += a[i - 1];
}
}
void solve()
{
for (int i = 1; i <= n; ++ i)
{
pre[i] = max(pre[i], pre[i - 1]);
dp[i] = dp[pre[i]] + 1;
int j = lower_bound(a + 1, a + n + 1, 2 * a[i] - a[pre[i]]) - a;
pre[j] = max(pre[j], i);
}
cout << dp[n];
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
if (fopen(TASK".INP", "r"))
{
freopen(TASK".INP", "r", stdin);
//freopen(TASK".OUT", "w", stdout);
}
int t = 1;
bool typetest = false;
if (typetest)
{
cin >> t;
}
for (int __ = 1; __ <= t; ++ __)
{
//cout << "Case " << __ << ": ";
read();
solve();
}
}
Compilation message (stderr)
# | 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... |