Submission #222697

# Submission time Handle Problem Language Result Execution time Memory
222697 2020-04-13T18:06:38 Z opukittpceno_hhr Candies (JOI18_candies) C++17
8 / 100
60 ms 64120 KB
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int N = 2001;
const int INF = 1e18 + 239;

int a[N];
int dp[N][N];

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	for (int i = 0; i < N; i++) {
		fill(dp[i], dp[i] + N, -INF);
	}

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= (i + 1) / 2; j++) {
			int c = a[i - 1];
			if (i - 2 >= 0 && j - 1 >= 0) {
				c += dp[i - 2][j - 1];
			}
			dp[i][j] = max(dp[i - 1][j], c);
		}
		dp[i][0] = 0;
	}
	for (int i = 1; i <= (n + 1) / 2; i++) {
		cout << dp[n][i] << ' ';
	}
	cout << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 27 ms 31744 KB Output is correct
2 Correct 23 ms 31744 KB Output is correct
3 Correct 24 ms 31744 KB Output is correct
4 Correct 24 ms 31744 KB Output is correct
5 Correct 23 ms 31744 KB Output is correct
6 Correct 24 ms 31744 KB Output is correct
7 Correct 25 ms 31744 KB Output is correct
8 Correct 23 ms 31744 KB Output is correct
9 Correct 24 ms 31744 KB Output is correct
10 Correct 24 ms 31744 KB Output is correct
11 Correct 23 ms 31736 KB Output is correct
12 Correct 24 ms 31744 KB Output is correct
13 Correct 24 ms 31744 KB Output is correct
14 Correct 24 ms 31744 KB Output is correct
15 Correct 24 ms 31744 KB Output is correct
16 Correct 24 ms 31744 KB Output is correct
17 Correct 24 ms 31744 KB Output is correct
18 Correct 24 ms 31744 KB Output is correct
19 Correct 24 ms 31744 KB Output is correct
20 Correct 23 ms 31744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 31744 KB Output is correct
2 Correct 23 ms 31744 KB Output is correct
3 Correct 24 ms 31744 KB Output is correct
4 Correct 24 ms 31744 KB Output is correct
5 Correct 23 ms 31744 KB Output is correct
6 Correct 24 ms 31744 KB Output is correct
7 Correct 25 ms 31744 KB Output is correct
8 Correct 23 ms 31744 KB Output is correct
9 Correct 24 ms 31744 KB Output is correct
10 Correct 24 ms 31744 KB Output is correct
11 Correct 23 ms 31736 KB Output is correct
12 Correct 24 ms 31744 KB Output is correct
13 Correct 24 ms 31744 KB Output is correct
14 Correct 24 ms 31744 KB Output is correct
15 Correct 24 ms 31744 KB Output is correct
16 Correct 24 ms 31744 KB Output is correct
17 Correct 24 ms 31744 KB Output is correct
18 Correct 24 ms 31744 KB Output is correct
19 Correct 24 ms 31744 KB Output is correct
20 Correct 23 ms 31744 KB Output is correct
21 Runtime error 60 ms 64120 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Halted 0 ms 0 KB -