Submission #48759

#TimeUsernameProblemLanguageResultExecution timeMemory
48759rkocharyanCandies (JOI18_candies)C++14
0 / 100
61 ms31700 KiB
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <algorithm> #include <string> #include <vector> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <queue> #include <deque> #include <stack> #include <list> #include <bitset> #include <iomanip> #include <memory> #include <cstring> #include <cstdio> #include <cmath> #include <climits> #include <cassert> using namespace std; #define mp make_pair #define add push_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define mem(a,b) memset(a, b, sizeof(a)) #pragma GCC optimize("unroll-loops") typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ld; typedef pair <int, int> pii; typedef vector <int> lnum; const int N = (int)1e6 + 100; const int maxn = (int)1e3 + 100; const int base = (int)1e9; const int mod = (int)1e9 + 7; const int inf = INT_MAX; const long long ll_inf = LLONG_MAX; const long double PI = acos((long double)-1.0); const long double eps = 1e-8; long long dp[2003][2003], A[2003]; void solve() { int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> A[i]; int to = (n + 1) / 2; for (int i = 0; i <= n; ++i) { for (int j = 0; j <= n; ++j) { dp[i][j] = -inf; } } dp[0][0] = dp[0][1] = 0; dp[1][1] = A[1]; for (int j = 2; j <= n; ++j) { for (int i = 0; i <= j; ++i) { dp[i][j] = dp[i][j - 1]; if (i) dp[i][j] = max(dp[i][j], dp[i - 1][j - 2] + A[j]); } } for (int i = 1; i <= to; ++i) cout << dp[i][n] << '\n'; } int main() { //ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); //#define Freopen #ifdef Freopen #ifndef _MSC_VER #define TASK "" freopen(TASK".in", "r", stdin); freopen(TASK".out", "w", stdout); #endif #endif int T = 1; //scanf("%d", &T); for (; T; --T) solve(); #ifdef DEBUG cerr << double(1.0 * clock() / CLOCKS_PER_SEC) << '\n'; #endif return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...