| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1350302 | tamir1 | Bigger segments (IZhO19_segments) | C++20 | 0 ms | 344 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
const int inf = 1e18;
signed main() {
int n;
cin >> n;
vector<int> a(n + 1);
for(int i = 1; i <= n; i++) cin >> a[i];
vector<pair<int, int>> dp(n + 1, {0, inf});
vector<int> p(n + 1, 0);
for(int i = 1; i <= n; i++) {
p[i] = p[i - 1] + a[i];
}
dp[0] = {0, 0};
for(int i = 1; i <= n; i++) {
int j = i;
for(int k = 20; k >= 0; k--) {
int j_ = j - (1 << k);
if(j_ >= 0 && dp[j_].ss > p[i] - p[j_]) j = j_;
}
j--;
dp[i] = {dp[j].ff + 1, p[i] - p[j]};
}
cout << dp[n].ff << "\n";
return 0;
}| # | 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... | ||||
