제출 #1163317

#제출 시각아이디문제언어결과실행 시간메모리
1163317lopkusCandies (JOI18_candies)C++20
8 / 100
273 ms589824 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int64_t> a(n + 1); for(int i = 1; i <= n; i++) { cin >> a[i]; } vector<vector<int64_t>> dp(n + 1, vector<int64_t>(n + 1)); dp[1][1] = a[1]; for(int i = 2; i <= n; i++) { for(int j = 1; j <= (i + 1) / 2; j++) { dp[i][j] = max(dp[i][j], dp[i - 1][j]); dp[i][j] = max(dp[i][j], dp[i - 2][j - 1] + a[i]); } } for(int i = 1; i <= (n + 1) / 2; i++) { cout << dp[n][i] << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...