답안 #520606

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
520606 2022-01-30T10:22:28 Z kartel Cigle (COI21_cigle) C++14
48 / 100
115 ms 2380 KB
#include <bits/stdc++.h>
//#include<ext/rope>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

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


#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define F first
#define S second
#define pb push_back
#define sz(x) int(x.size())
#define el '\n'
#define all(x) x.begin(), x.end()

using namespace std;
//using namespace __gnu_pbds;
//using  namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef short int si;
typedef unsigned long long ull;
//typedef tree <ll, null_type, less <ll> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 505;

int n, f[N][N], a[N];

int main()
{
//    cerr.precision(7);
//    cerr << fixed;
    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    in("23.in");
//    in("input.txt");
//    out("output.txt");
//    clock_t start = clock();

    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++) {
            f[i][j] = -1e9;
        }
    }
    for (int i = 1; i <= n; i++) {
        f[1][i] = 0;
    }
    for (int i = 1; i <= n; i++) {
        int sum_now = 0;
        for (int j = i; j <= n; j++) {
            sum_now += a[j];
            int pj = j;
            int sum = 0;
            int sum_was = 0;
            int cnt = -1;
            for (int k = j + 1; k <= n; k++) {
                if (sum_was == sum && pj >= i) {
                    cnt++;
                }
                sum += a[k];
                while (pj >= i && sum_was < sum) {
                    sum_was += a[pj];
                    pj--;
                }
//                if (j + 1 == 9 && k == 12) {
//                    cout << i << " " << j << " " << f[i][j] + cnt << el;
//                }
                f[j + 1][k] = max(f[j + 1][k], f[i][j] + cnt);
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, f[i][n]);
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 232 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 232 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 1228 KB Output is correct
2 Correct 53 ms 1336 KB Output is correct
3 Correct 50 ms 1292 KB Output is correct
4 Correct 47 ms 1288 KB Output is correct
5 Correct 48 ms 1228 KB Output is correct
6 Correct 99 ms 1292 KB Output is correct
7 Correct 115 ms 1292 KB Output is correct
8 Correct 89 ms 1228 KB Output is correct
9 Correct 108 ms 1296 KB Output is correct
10 Correct 53 ms 1228 KB Output is correct
11 Correct 62 ms 1300 KB Output is correct
12 Correct 54 ms 1292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 232 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 42 ms 1228 KB Output is correct
22 Correct 53 ms 1336 KB Output is correct
23 Correct 50 ms 1292 KB Output is correct
24 Correct 47 ms 1288 KB Output is correct
25 Correct 48 ms 1228 KB Output is correct
26 Correct 99 ms 1292 KB Output is correct
27 Correct 115 ms 1292 KB Output is correct
28 Correct 89 ms 1228 KB Output is correct
29 Correct 108 ms 1296 KB Output is correct
30 Correct 53 ms 1228 KB Output is correct
31 Correct 62 ms 1300 KB Output is correct
32 Correct 54 ms 1292 KB Output is correct
33 Correct 43 ms 1288 KB Output is correct
34 Correct 45 ms 1300 KB Output is correct
35 Correct 47 ms 1336 KB Output is correct
36 Correct 45 ms 1228 KB Output is correct
37 Correct 89 ms 1288 KB Output is correct
38 Correct 89 ms 1228 KB Output is correct
39 Correct 112 ms 1292 KB Output is correct
40 Correct 98 ms 1312 KB Output is correct
41 Correct 77 ms 1304 KB Output is correct
42 Correct 73 ms 1228 KB Output is correct
43 Correct 73 ms 1296 KB Output is correct
44 Correct 84 ms 1228 KB Output is correct
45 Correct 62 ms 1288 KB Output is correct
46 Correct 68 ms 1228 KB Output is correct
47 Correct 83 ms 1296 KB Output is correct
48 Correct 63 ms 1228 KB Output is correct
49 Correct 63 ms 1292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 232 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 42 ms 1228 KB Output is correct
22 Correct 53 ms 1336 KB Output is correct
23 Correct 50 ms 1292 KB Output is correct
24 Correct 47 ms 1288 KB Output is correct
25 Correct 48 ms 1228 KB Output is correct
26 Correct 99 ms 1292 KB Output is correct
27 Correct 115 ms 1292 KB Output is correct
28 Correct 89 ms 1228 KB Output is correct
29 Correct 108 ms 1296 KB Output is correct
30 Correct 53 ms 1228 KB Output is correct
31 Correct 62 ms 1300 KB Output is correct
32 Correct 54 ms 1292 KB Output is correct
33 Correct 43 ms 1288 KB Output is correct
34 Correct 45 ms 1300 KB Output is correct
35 Correct 47 ms 1336 KB Output is correct
36 Correct 45 ms 1228 KB Output is correct
37 Correct 89 ms 1288 KB Output is correct
38 Correct 89 ms 1228 KB Output is correct
39 Correct 112 ms 1292 KB Output is correct
40 Correct 98 ms 1312 KB Output is correct
41 Correct 77 ms 1304 KB Output is correct
42 Correct 73 ms 1228 KB Output is correct
43 Correct 73 ms 1296 KB Output is correct
44 Correct 84 ms 1228 KB Output is correct
45 Correct 62 ms 1288 KB Output is correct
46 Correct 68 ms 1228 KB Output is correct
47 Correct 83 ms 1296 KB Output is correct
48 Correct 63 ms 1228 KB Output is correct
49 Correct 63 ms 1292 KB Output is correct
50 Runtime error 4 ms 2380 KB Execution killed with signal 11
51 Halted 0 ms 0 KB -