| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1172024 | AtabayRajabli | Bigger segments (IZhO19_segments) | C++20 | 0 ms | 324 KiB |
#include <bits/stdc++.h>
#define int long long
#define all(v) v.begin(), v.end()
using namespace std;
const int sz = 3e3 + 1, inf = 1e18;
int n, a[sz], dp[sz][sz];
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i++)
{
cin >> a[i];
a[i] += a[i - 1];
}
// dp[i][j][k] -> ends at i, j blocks
for(int i = 0; i <= n; i++) fill(dp[i], dp[i] + 1 + n, inf);
dp[0][0] = 0;
for(int i = 1; i <= n; i++)
{
dp[i][0] = 0;
for(int j = 1; j <= i; j++)
{
dp[i][j] = dp[i - 1][j];
for(int k = j; k <= i; k++)
{
int sm = a[i] - a[k - 1];
if(sm >= dp[k - 1][j - 1]) dp[i][j] = min(dp[i][j], sm);
}
}
}
int last = -1;
for(int i = 1; i <= n; i++)
{
if(dp[n][i] != inf) last = i;
}
cout << last;
}| # | 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... | ||||
