답안 #520607

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
520607 2022-01-30T10:29:29 Z Vimmer Cigle (COI21_cigle) C++14
48 / 100
1000 ms 196488 KB
#include <bits/stdc++.h>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")

#define F first
#define S second
#define PB push_back
#define M ll(1e9 + 7)
#define sz(x) (ll)x.size()
#define N 1000500
#define pri(x) cout << x << endl
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

using namespace std;
//typedef tree <ll, null_type, less_equal <ll> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef short int si;
typedef unsigned long long ull;

int f[5005][5005][2];

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

    memset(f, -1, sizeof f);

    int n;

    cin >> n;

    int a[n], ans = 0;

    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 0; i < n; i++)
        f[0][i][0] = 0;

    for (int r = 0; r < n; r++)
        for (int l = 0; l <= r; l++)
            for (int t = 0; t < 2; t++)
                if (f[l][r][t] != -1)
                {
                    int kl = f[l][r][t];

                    int u = r, sm = 0, cur = 0;

                    for (int nw = r + 1; nw < n; nw++)
                    {
                        if (cur == sm && u != l - 1 && nw != r + 1 && u != r)
                            kl++;

                        cur += a[nw];

                        while (u >= l && cur > sm)
                        {
                            sm += a[u];

                            u--;
                        }

                        f[r + 1][nw][t ^ 1] = max(f[r + 1][nw][t ^ 1], kl);

                        ans = max(ans, kl);
                    }
                }

    pri(ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 196276 KB Output is correct
2 Correct 94 ms 196268 KB Output is correct
3 Correct 70 ms 196332 KB Output is correct
4 Correct 68 ms 196292 KB Output is correct
5 Correct 71 ms 196360 KB Output is correct
6 Correct 69 ms 196368 KB Output is correct
7 Correct 81 ms 196264 KB Output is correct
8 Correct 78 ms 196332 KB Output is correct
9 Correct 69 ms 196292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 196276 KB Output is correct
2 Correct 94 ms 196268 KB Output is correct
3 Correct 70 ms 196332 KB Output is correct
4 Correct 68 ms 196292 KB Output is correct
5 Correct 71 ms 196360 KB Output is correct
6 Correct 69 ms 196368 KB Output is correct
7 Correct 81 ms 196264 KB Output is correct
8 Correct 78 ms 196332 KB Output is correct
9 Correct 69 ms 196292 KB Output is correct
10 Correct 69 ms 196388 KB Output is correct
11 Correct 69 ms 196332 KB Output is correct
12 Correct 73 ms 196356 KB Output is correct
13 Correct 71 ms 196328 KB Output is correct
14 Correct 73 ms 196276 KB Output is correct
15 Correct 71 ms 196372 KB Output is correct
16 Correct 73 ms 196452 KB Output is correct
17 Correct 122 ms 196348 KB Output is correct
18 Correct 94 ms 196312 KB Output is correct
19 Correct 69 ms 196360 KB Output is correct
20 Correct 70 ms 196268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 163 ms 196372 KB Output is correct
2 Correct 174 ms 196356 KB Output is correct
3 Correct 173 ms 196376 KB Output is correct
4 Correct 174 ms 196376 KB Output is correct
5 Correct 183 ms 196268 KB Output is correct
6 Correct 199 ms 196360 KB Output is correct
7 Correct 190 ms 196372 KB Output is correct
8 Correct 167 ms 196372 KB Output is correct
9 Correct 166 ms 196356 KB Output is correct
10 Correct 175 ms 196300 KB Output is correct
11 Correct 165 ms 196292 KB Output is correct
12 Correct 165 ms 196348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 196276 KB Output is correct
2 Correct 94 ms 196268 KB Output is correct
3 Correct 70 ms 196332 KB Output is correct
4 Correct 68 ms 196292 KB Output is correct
5 Correct 71 ms 196360 KB Output is correct
6 Correct 69 ms 196368 KB Output is correct
7 Correct 81 ms 196264 KB Output is correct
8 Correct 78 ms 196332 KB Output is correct
9 Correct 69 ms 196292 KB Output is correct
10 Correct 69 ms 196388 KB Output is correct
11 Correct 69 ms 196332 KB Output is correct
12 Correct 73 ms 196356 KB Output is correct
13 Correct 71 ms 196328 KB Output is correct
14 Correct 73 ms 196276 KB Output is correct
15 Correct 71 ms 196372 KB Output is correct
16 Correct 73 ms 196452 KB Output is correct
17 Correct 122 ms 196348 KB Output is correct
18 Correct 94 ms 196312 KB Output is correct
19 Correct 69 ms 196360 KB Output is correct
20 Correct 70 ms 196268 KB Output is correct
21 Correct 163 ms 196372 KB Output is correct
22 Correct 174 ms 196356 KB Output is correct
23 Correct 173 ms 196376 KB Output is correct
24 Correct 174 ms 196376 KB Output is correct
25 Correct 183 ms 196268 KB Output is correct
26 Correct 199 ms 196360 KB Output is correct
27 Correct 190 ms 196372 KB Output is correct
28 Correct 167 ms 196372 KB Output is correct
29 Correct 166 ms 196356 KB Output is correct
30 Correct 175 ms 196300 KB Output is correct
31 Correct 165 ms 196292 KB Output is correct
32 Correct 165 ms 196348 KB Output is correct
33 Correct 166 ms 196380 KB Output is correct
34 Correct 170 ms 196304 KB Output is correct
35 Correct 166 ms 196372 KB Output is correct
36 Correct 173 ms 196292 KB Output is correct
37 Correct 186 ms 196376 KB Output is correct
38 Correct 171 ms 196376 KB Output is correct
39 Correct 161 ms 196376 KB Output is correct
40 Correct 153 ms 196312 KB Output is correct
41 Correct 153 ms 196380 KB Output is correct
42 Correct 150 ms 196272 KB Output is correct
43 Correct 157 ms 196380 KB Output is correct
44 Correct 167 ms 196488 KB Output is correct
45 Correct 149 ms 196260 KB Output is correct
46 Correct 155 ms 196376 KB Output is correct
47 Correct 178 ms 196272 KB Output is correct
48 Correct 161 ms 196376 KB Output is correct
49 Correct 151 ms 196272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 196276 KB Output is correct
2 Correct 94 ms 196268 KB Output is correct
3 Correct 70 ms 196332 KB Output is correct
4 Correct 68 ms 196292 KB Output is correct
5 Correct 71 ms 196360 KB Output is correct
6 Correct 69 ms 196368 KB Output is correct
7 Correct 81 ms 196264 KB Output is correct
8 Correct 78 ms 196332 KB Output is correct
9 Correct 69 ms 196292 KB Output is correct
10 Correct 69 ms 196388 KB Output is correct
11 Correct 69 ms 196332 KB Output is correct
12 Correct 73 ms 196356 KB Output is correct
13 Correct 71 ms 196328 KB Output is correct
14 Correct 73 ms 196276 KB Output is correct
15 Correct 71 ms 196372 KB Output is correct
16 Correct 73 ms 196452 KB Output is correct
17 Correct 122 ms 196348 KB Output is correct
18 Correct 94 ms 196312 KB Output is correct
19 Correct 69 ms 196360 KB Output is correct
20 Correct 70 ms 196268 KB Output is correct
21 Correct 163 ms 196372 KB Output is correct
22 Correct 174 ms 196356 KB Output is correct
23 Correct 173 ms 196376 KB Output is correct
24 Correct 174 ms 196376 KB Output is correct
25 Correct 183 ms 196268 KB Output is correct
26 Correct 199 ms 196360 KB Output is correct
27 Correct 190 ms 196372 KB Output is correct
28 Correct 167 ms 196372 KB Output is correct
29 Correct 166 ms 196356 KB Output is correct
30 Correct 175 ms 196300 KB Output is correct
31 Correct 165 ms 196292 KB Output is correct
32 Correct 165 ms 196348 KB Output is correct
33 Correct 166 ms 196380 KB Output is correct
34 Correct 170 ms 196304 KB Output is correct
35 Correct 166 ms 196372 KB Output is correct
36 Correct 173 ms 196292 KB Output is correct
37 Correct 186 ms 196376 KB Output is correct
38 Correct 171 ms 196376 KB Output is correct
39 Correct 161 ms 196376 KB Output is correct
40 Correct 153 ms 196312 KB Output is correct
41 Correct 153 ms 196380 KB Output is correct
42 Correct 150 ms 196272 KB Output is correct
43 Correct 157 ms 196380 KB Output is correct
44 Correct 167 ms 196488 KB Output is correct
45 Correct 149 ms 196260 KB Output is correct
46 Correct 155 ms 196376 KB Output is correct
47 Correct 178 ms 196272 KB Output is correct
48 Correct 161 ms 196376 KB Output is correct
49 Correct 151 ms 196272 KB Output is correct
50 Execution timed out 1088 ms 196288 KB Time limit exceeded
51 Halted 0 ms 0 KB -