Submission #331521

# Submission time Handle Problem Language Result Execution time Memory
331521 2020-11-28T18:47:31 Z limabeans Bigger segments (IZhO19_segments) C++17
27 / 100
114 ms 2412 KB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;
const ll inf = 1e18;


const int maxn = 505;



int n;
ll a[maxn];
ll dp[maxn][maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    cin>>n;
    for (int i=1; i<=n; i++) {
	cin>>a[i];
    }

    for (int i=0; i<=n; i++) {
	for (int j=0; j<=n; j++) {
	    dp[i][j] = inf;
	}
    }

    dp[0][0] = 0;
    for (int i=1; i<=n; i++) {
	for (int j=1; j<=i; j++) {
	    ll sum = 0;
	    for (int k=i; k>=1; k--) {
		sum += a[k];
		if (dp[k-1][j-1] <= sum) {
		    dp[i][j] = min(dp[i][j], sum);
		}
	    }
	}
    }

    int res = 0;
    for (int j=1; j<=n; j++) {
	if (dp[n][j]<inf) res = j;
    }

    cout<<res<<endl;    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 69 ms 2284 KB Output is correct
17 Correct 83 ms 2284 KB Output is correct
18 Correct 75 ms 2412 KB Output is correct
19 Correct 97 ms 2284 KB Output is correct
20 Correct 113 ms 2412 KB Output is correct
21 Correct 73 ms 2284 KB Output is correct
22 Correct 37 ms 1900 KB Output is correct
23 Correct 16 ms 1592 KB Output is correct
24 Correct 75 ms 2284 KB Output is correct
25 Correct 73 ms 2284 KB Output is correct
26 Correct 114 ms 2304 KB Output is correct
27 Correct 79 ms 2284 KB Output is correct
28 Correct 79 ms 2412 KB Output is correct
29 Correct 112 ms 2284 KB Output is correct
30 Correct 110 ms 2284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 69 ms 2284 KB Output is correct
17 Correct 83 ms 2284 KB Output is correct
18 Correct 75 ms 2412 KB Output is correct
19 Correct 97 ms 2284 KB Output is correct
20 Correct 113 ms 2412 KB Output is correct
21 Correct 73 ms 2284 KB Output is correct
22 Correct 37 ms 1900 KB Output is correct
23 Correct 16 ms 1592 KB Output is correct
24 Correct 75 ms 2284 KB Output is correct
25 Correct 73 ms 2284 KB Output is correct
26 Correct 114 ms 2304 KB Output is correct
27 Correct 79 ms 2284 KB Output is correct
28 Correct 79 ms 2412 KB Output is correct
29 Correct 112 ms 2284 KB Output is correct
30 Correct 110 ms 2284 KB Output is correct
31 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 69 ms 2284 KB Output is correct
17 Correct 83 ms 2284 KB Output is correct
18 Correct 75 ms 2412 KB Output is correct
19 Correct 97 ms 2284 KB Output is correct
20 Correct 113 ms 2412 KB Output is correct
21 Correct 73 ms 2284 KB Output is correct
22 Correct 37 ms 1900 KB Output is correct
23 Correct 16 ms 1592 KB Output is correct
24 Correct 75 ms 2284 KB Output is correct
25 Correct 73 ms 2284 KB Output is correct
26 Correct 114 ms 2304 KB Output is correct
27 Correct 79 ms 2284 KB Output is correct
28 Correct 79 ms 2412 KB Output is correct
29 Correct 112 ms 2284 KB Output is correct
30 Correct 110 ms 2284 KB Output is correct
31 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 69 ms 2284 KB Output is correct
17 Correct 83 ms 2284 KB Output is correct
18 Correct 75 ms 2412 KB Output is correct
19 Correct 97 ms 2284 KB Output is correct
20 Correct 113 ms 2412 KB Output is correct
21 Correct 73 ms 2284 KB Output is correct
22 Correct 37 ms 1900 KB Output is correct
23 Correct 16 ms 1592 KB Output is correct
24 Correct 75 ms 2284 KB Output is correct
25 Correct 73 ms 2284 KB Output is correct
26 Correct 114 ms 2304 KB Output is correct
27 Correct 79 ms 2284 KB Output is correct
28 Correct 79 ms 2412 KB Output is correct
29 Correct 112 ms 2284 KB Output is correct
30 Correct 110 ms 2284 KB Output is correct
31 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Halted 0 ms 0 KB -