Submission #245809

# Submission time Handle Problem Language Result Execution time Memory
245809 2020-07-07T13:10:57 Z RealSuperman1 Candies (JOI18_candies) C++17
8 / 100
29 ms 16384 KB
//#pragma comment(linker, "\stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcount,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<
	ll,
	null_type,
	less_equal<ll>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
	

const int N = 2e3 + 10;
const int mod = 1e9 + 7;


ll n, a[N], dp[N][N];


int main() {
	ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
// 	freopen("input.txt", "r", stdin);
// 	freopen("input.in", "r", stdin);
// 	freopen("input.out", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        dp[i][1] = max(dp[i - 1][1], a[i]);
    ll lim = (n + 1) / 2;
    for (int j = 2; j <= lim; j++) {
        for (int i = 2 * j - 1; i <= n; i++)
            dp[i][j] = max(dp[i - 1][j], dp[i - 2][j - 1] + a[i]);
    }
    for (int j = 1; j <= lim; j++)
        cout << dp[n][j] << "\n";
}

# Verdict Execution time Memory Grader output
1 Correct 23 ms 16256 KB Output is correct
2 Correct 22 ms 16248 KB Output is correct
3 Correct 22 ms 16256 KB Output is correct
4 Correct 22 ms 16256 KB Output is correct
5 Correct 22 ms 16256 KB Output is correct
6 Correct 22 ms 16256 KB Output is correct
7 Correct 22 ms 16256 KB Output is correct
8 Correct 22 ms 16256 KB Output is correct
9 Correct 22 ms 16256 KB Output is correct
10 Correct 22 ms 16256 KB Output is correct
11 Correct 23 ms 16384 KB Output is correct
12 Correct 22 ms 16256 KB Output is correct
13 Correct 23 ms 16256 KB Output is correct
14 Correct 24 ms 16256 KB Output is correct
15 Correct 23 ms 16256 KB Output is correct
16 Correct 29 ms 16256 KB Output is correct
17 Correct 22 ms 16248 KB Output is correct
18 Correct 22 ms 16248 KB Output is correct
19 Correct 23 ms 16256 KB Output is correct
20 Correct 23 ms 16256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 16256 KB Output is correct
2 Correct 22 ms 16248 KB Output is correct
3 Correct 22 ms 16256 KB Output is correct
4 Correct 22 ms 16256 KB Output is correct
5 Correct 22 ms 16256 KB Output is correct
6 Correct 22 ms 16256 KB Output is correct
7 Correct 22 ms 16256 KB Output is correct
8 Correct 22 ms 16256 KB Output is correct
9 Correct 22 ms 16256 KB Output is correct
10 Correct 22 ms 16256 KB Output is correct
11 Correct 23 ms 16384 KB Output is correct
12 Correct 22 ms 16256 KB Output is correct
13 Correct 23 ms 16256 KB Output is correct
14 Correct 24 ms 16256 KB Output is correct
15 Correct 23 ms 16256 KB Output is correct
16 Correct 29 ms 16256 KB Output is correct
17 Correct 22 ms 16248 KB Output is correct
18 Correct 22 ms 16248 KB Output is correct
19 Correct 23 ms 16256 KB Output is correct
20 Correct 23 ms 16256 KB Output is correct
21 Runtime error 7 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Halted 0 ms 0 KB -