Submission #672058

# Submission time Handle Problem Language Result Execution time Memory
672058 2022-12-14T16:42:14 Z Username4132 Cigle (COI21_cigle) C++14
100 / 100
486 ms 134388 KB
#include<iostream>
#include "stdio.h"
#include<algorithm>
using namespace std;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forsn(i, s, n) for(int i=s; i<(int)n; ++i)
#define dforn(i, n) for(int i=n-1; i>=0; --i)
#define dforsn(i, s, n) for(int i=n-1; i>=(int)s; --i)

const int MAXN = 5010;
int n, mx, tmp, sum[MAXN], value[MAXN][MAXN], dp[MAXN][MAXN];

int main(){
    cin >> n;
    forn(i, n) scanf("%d", &tmp), sum[i+1] = sum[i] + tmp;

    dforn(i, n) dforsn(j, i+2, n){
        int pos = lower_bound(sum, sum+n, 2*sum[j]-sum[i+1]) - sum;
        value[i][j] = value[i+1][j]+(pos<n && sum[pos]==2*sum[j]-sum[i+1]);
        dp[i][j] = max(dp[i+1][j], dp[i][j+1]);
        if(pos<n) dp[i][j] = max(dp[i][j], value[i][j] + dp[j][pos+1]);
    }

    forn(i, n) mx = max(mx, dp[0][i]);
    printf("%d\n", mx);
}

Compilation message

cigle.cpp: In function 'int main()':
cigle.cpp:15:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     forn(i, n) scanf("%d", &tmp), sum[i+1] = sum[i] + tmp;
      |                ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 436 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 436 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 852 KB Output is correct
11 Correct 1 ms 852 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 852 KB Output is correct
15 Correct 1 ms 852 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 1 ms 948 KB Output is correct
19 Correct 1 ms 944 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 5204 KB Output is correct
2 Correct 5 ms 5204 KB Output is correct
3 Correct 5 ms 5204 KB Output is correct
4 Correct 5 ms 5204 KB Output is correct
5 Correct 6 ms 5204 KB Output is correct
6 Correct 6 ms 5240 KB Output is correct
7 Correct 6 ms 5204 KB Output is correct
8 Correct 5 ms 5296 KB Output is correct
9 Correct 5 ms 5204 KB Output is correct
10 Correct 5 ms 5192 KB Output is correct
11 Correct 6 ms 5204 KB Output is correct
12 Correct 5 ms 5300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 436 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 852 KB Output is correct
11 Correct 1 ms 852 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 852 KB Output is correct
15 Correct 1 ms 852 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 1 ms 948 KB Output is correct
19 Correct 1 ms 944 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 5 ms 5204 KB Output is correct
22 Correct 5 ms 5204 KB Output is correct
23 Correct 5 ms 5204 KB Output is correct
24 Correct 5 ms 5204 KB Output is correct
25 Correct 6 ms 5204 KB Output is correct
26 Correct 6 ms 5240 KB Output is correct
27 Correct 6 ms 5204 KB Output is correct
28 Correct 5 ms 5296 KB Output is correct
29 Correct 5 ms 5204 KB Output is correct
30 Correct 5 ms 5192 KB Output is correct
31 Correct 6 ms 5204 KB Output is correct
32 Correct 5 ms 5300 KB Output is correct
33 Correct 5 ms 5204 KB Output is correct
34 Correct 6 ms 5204 KB Output is correct
35 Correct 5 ms 5296 KB Output is correct
36 Correct 5 ms 5204 KB Output is correct
37 Correct 6 ms 5192 KB Output is correct
38 Correct 5 ms 5204 KB Output is correct
39 Correct 6 ms 5204 KB Output is correct
40 Correct 5 ms 5204 KB Output is correct
41 Correct 5 ms 5300 KB Output is correct
42 Correct 5 ms 5204 KB Output is correct
43 Correct 5 ms 5288 KB Output is correct
44 Correct 6 ms 5272 KB Output is correct
45 Correct 5 ms 5204 KB Output is correct
46 Correct 6 ms 5204 KB Output is correct
47 Correct 6 ms 5204 KB Output is correct
48 Correct 6 ms 5304 KB Output is correct
49 Correct 5 ms 5204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 436 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 852 KB Output is correct
11 Correct 1 ms 852 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 852 KB Output is correct
15 Correct 1 ms 852 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 1 ms 948 KB Output is correct
19 Correct 1 ms 944 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 5 ms 5204 KB Output is correct
22 Correct 5 ms 5204 KB Output is correct
23 Correct 5 ms 5204 KB Output is correct
24 Correct 5 ms 5204 KB Output is correct
25 Correct 6 ms 5204 KB Output is correct
26 Correct 6 ms 5240 KB Output is correct
27 Correct 6 ms 5204 KB Output is correct
28 Correct 5 ms 5296 KB Output is correct
29 Correct 5 ms 5204 KB Output is correct
30 Correct 5 ms 5192 KB Output is correct
31 Correct 6 ms 5204 KB Output is correct
32 Correct 5 ms 5300 KB Output is correct
33 Correct 5 ms 5204 KB Output is correct
34 Correct 6 ms 5204 KB Output is correct
35 Correct 5 ms 5296 KB Output is correct
36 Correct 5 ms 5204 KB Output is correct
37 Correct 6 ms 5192 KB Output is correct
38 Correct 5 ms 5204 KB Output is correct
39 Correct 6 ms 5204 KB Output is correct
40 Correct 5 ms 5204 KB Output is correct
41 Correct 5 ms 5300 KB Output is correct
42 Correct 5 ms 5204 KB Output is correct
43 Correct 5 ms 5288 KB Output is correct
44 Correct 6 ms 5272 KB Output is correct
45 Correct 5 ms 5204 KB Output is correct
46 Correct 6 ms 5204 KB Output is correct
47 Correct 6 ms 5204 KB Output is correct
48 Correct 6 ms 5304 KB Output is correct
49 Correct 5 ms 5204 KB Output is correct
50 Correct 471 ms 134164 KB Output is correct
51 Correct 486 ms 134112 KB Output is correct
52 Correct 467 ms 134248 KB Output is correct
53 Correct 470 ms 134156 KB Output is correct
54 Correct 466 ms 134164 KB Output is correct
55 Correct 475 ms 134156 KB Output is correct
56 Correct 462 ms 134140 KB Output is correct
57 Correct 461 ms 134168 KB Output is correct
58 Correct 460 ms 134200 KB Output is correct
59 Correct 438 ms 134132 KB Output is correct
60 Correct 451 ms 134256 KB Output is correct
61 Correct 434 ms 134176 KB Output is correct
62 Correct 441 ms 134220 KB Output is correct
63 Correct 444 ms 134388 KB Output is correct
64 Correct 438 ms 134124 KB Output is correct
65 Correct 450 ms 134372 KB Output is correct
66 Correct 438 ms 134176 KB Output is correct
67 Correct 434 ms 134320 KB Output is correct
68 Correct 427 ms 134204 KB Output is correct
69 Correct 427 ms 134164 KB Output is correct
70 Correct 457 ms 134236 KB Output is correct
71 Correct 435 ms 134204 KB Output is correct
72 Correct 455 ms 134168 KB Output is correct