제출 #1268183

#제출 시각아이디문제언어결과실행 시간메모리
1268183boss_zzCandies (JOI18_candies)C++20
8 / 100
10 ms23112 KiB
#include<bits/stdc++.h>
#define rep(a,b,c) for(ll a=b;a<=c;++a)
#define ll long long 
#define ff first 
#define ss second 
#define mp make_pair 
using namespace std;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll N=2005,inf=1e18;
ll n,A[N],dp[N][N];
ll Ceil(ll a,ll b){return (a+b-1)/b;}
signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    rep(i,1,n) cin>>A[i];
    rep(i,1,n) rep(j,1,i) dp[i][j]=-inf; 
    dp[1][1]=A[1];
    rep(i,2,n) rep(j,1,Ceil(i,2)) dp[i][j]=max(dp[i-1][j],dp[i-2][j-1]+A[i]);
    rep(i,1,Ceil(n,2)) cout<<dp[n][i]<<'\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...