Submission #222697

#TimeUsernameProblemLanguageResultExecution timeMemory
222697opukittpceno_hhrCandies (JOI18_candies)C++17
8 / 100
60 ms64120 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...