Submission #905875

# Submission time Handle Problem Language Result Execution time Memory
905875 2024-01-13T05:54:05 Z Blistering_Barnacles Cigle (COI21_cigle) C++17
100 / 100
126 ms 171468 KB
//Billions of bilious blue blistering barnacles in a thundering typhoon!
//Yesterday is history, tomorrow is a mystery, today is a gift of God, which is why we call it the present.
#include<bits/stdc++.h>
#define F first 
#define S second
#define lx node * 2
#define rx node * 2 + 1
#define md ((s + e) / 2)
#define mid (l + (r - l) / 2)
#define all(x) x.begin(), x.end()
typedef long long ll;
using namespace std;
int a[5005], dp[5005][5005], Dp[5005][5005];
void solve(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int sumL = 0, sumR = 0, cnt = 0;
        int k = i - 1;
        for(int j = i + 1; j <= n; j++){
            dp[i][j] = dp[i][j - 1];
            sumR += a[j - 1];
            while(k > 1 && sumL < sumR){
                sumL += a[k--];
            }
            cnt += (sumL == sumR);
            dp[i][j] = max(dp[i][j], Dp[k][i - 1] + cnt);
            Dp[i][j] = max(Dp[i - 1][j], dp[i][j]);
        }
        ans = max(ans, dp[i][n]);
    }
    cout << ans << "\n";
}
int main(){
    ios::sync_with_stdio(0), cin.tie(0); 
    int tt = 1; 
    //cin >> tt; 
    while(tt--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2400 KB Output is correct
7 Correct 1 ms 2780 KB Output is correct
8 Correct 1 ms 2400 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2400 KB Output is correct
7 Correct 1 ms 2780 KB Output is correct
8 Correct 1 ms 2400 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 1 ms 2904 KB Output is correct
18 Correct 1 ms 2860 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 13148 KB Output is correct
2 Correct 4 ms 13148 KB Output is correct
3 Correct 4 ms 13148 KB Output is correct
4 Correct 4 ms 13148 KB Output is correct
5 Correct 4 ms 13148 KB Output is correct
6 Correct 4 ms 13148 KB Output is correct
7 Correct 5 ms 13148 KB Output is correct
8 Correct 6 ms 13148 KB Output is correct
9 Correct 4 ms 13236 KB Output is correct
10 Correct 4 ms 13148 KB Output is correct
11 Correct 5 ms 13148 KB Output is correct
12 Correct 4 ms 13192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2400 KB Output is correct
7 Correct 1 ms 2780 KB Output is correct
8 Correct 1 ms 2400 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 1 ms 2904 KB Output is correct
18 Correct 1 ms 2860 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 4 ms 13148 KB Output is correct
22 Correct 4 ms 13148 KB Output is correct
23 Correct 4 ms 13148 KB Output is correct
24 Correct 4 ms 13148 KB Output is correct
25 Correct 4 ms 13148 KB Output is correct
26 Correct 4 ms 13148 KB Output is correct
27 Correct 5 ms 13148 KB Output is correct
28 Correct 6 ms 13148 KB Output is correct
29 Correct 4 ms 13236 KB Output is correct
30 Correct 4 ms 13148 KB Output is correct
31 Correct 5 ms 13148 KB Output is correct
32 Correct 4 ms 13192 KB Output is correct
33 Correct 4 ms 13264 KB Output is correct
34 Correct 4 ms 13148 KB Output is correct
35 Correct 4 ms 13148 KB Output is correct
36 Correct 4 ms 13148 KB Output is correct
37 Correct 4 ms 13148 KB Output is correct
38 Correct 4 ms 13148 KB Output is correct
39 Correct 4 ms 13148 KB Output is correct
40 Correct 4 ms 13148 KB Output is correct
41 Correct 4 ms 13148 KB Output is correct
42 Correct 4 ms 13148 KB Output is correct
43 Correct 4 ms 13148 KB Output is correct
44 Correct 5 ms 13148 KB Output is correct
45 Correct 4 ms 13400 KB Output is correct
46 Correct 4 ms 13556 KB Output is correct
47 Correct 5 ms 13244 KB Output is correct
48 Correct 4 ms 13148 KB Output is correct
49 Correct 4 ms 13148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2400 KB Output is correct
7 Correct 1 ms 2780 KB Output is correct
8 Correct 1 ms 2400 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 1 ms 2904 KB Output is correct
18 Correct 1 ms 2860 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 4 ms 13148 KB Output is correct
22 Correct 4 ms 13148 KB Output is correct
23 Correct 4 ms 13148 KB Output is correct
24 Correct 4 ms 13148 KB Output is correct
25 Correct 4 ms 13148 KB Output is correct
26 Correct 4 ms 13148 KB Output is correct
27 Correct 5 ms 13148 KB Output is correct
28 Correct 6 ms 13148 KB Output is correct
29 Correct 4 ms 13236 KB Output is correct
30 Correct 4 ms 13148 KB Output is correct
31 Correct 5 ms 13148 KB Output is correct
32 Correct 4 ms 13192 KB Output is correct
33 Correct 4 ms 13264 KB Output is correct
34 Correct 4 ms 13148 KB Output is correct
35 Correct 4 ms 13148 KB Output is correct
36 Correct 4 ms 13148 KB Output is correct
37 Correct 4 ms 13148 KB Output is correct
38 Correct 4 ms 13148 KB Output is correct
39 Correct 4 ms 13148 KB Output is correct
40 Correct 4 ms 13148 KB Output is correct
41 Correct 4 ms 13148 KB Output is correct
42 Correct 4 ms 13148 KB Output is correct
43 Correct 4 ms 13148 KB Output is correct
44 Correct 5 ms 13148 KB Output is correct
45 Correct 4 ms 13400 KB Output is correct
46 Correct 4 ms 13556 KB Output is correct
47 Correct 5 ms 13244 KB Output is correct
48 Correct 4 ms 13148 KB Output is correct
49 Correct 4 ms 13148 KB Output is correct
50 Correct 101 ms 171244 KB Output is correct
51 Correct 104 ms 171452 KB Output is correct
52 Correct 91 ms 171348 KB Output is correct
53 Correct 93 ms 171344 KB Output is correct
54 Correct 95 ms 171284 KB Output is correct
55 Correct 97 ms 171296 KB Output is correct
56 Correct 122 ms 171244 KB Output is correct
57 Correct 105 ms 171296 KB Output is correct
58 Correct 119 ms 171436 KB Output is correct
59 Correct 118 ms 171300 KB Output is correct
60 Correct 126 ms 171268 KB Output is correct
61 Correct 109 ms 171344 KB Output is correct
62 Correct 104 ms 171436 KB Output is correct
63 Correct 102 ms 171256 KB Output is correct
64 Correct 111 ms 171240 KB Output is correct
65 Correct 110 ms 171468 KB Output is correct
66 Correct 102 ms 171460 KB Output is correct
67 Correct 97 ms 171460 KB Output is correct
68 Correct 97 ms 171348 KB Output is correct
69 Correct 95 ms 171348 KB Output is correct
70 Correct 116 ms 171288 KB Output is correct
71 Correct 119 ms 171388 KB Output is correct
72 Correct 117 ms 171352 KB Output is correct