답안 #861123

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861123 2023-10-15T11:16:39 Z eitanelb Candies (JOI18_candies) C++14
8 / 100
201 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int n; cin>>n;
    vector<ll> v(n); for(ll &i : v) cin>>i;
    int k = (n+1)/2;
    vector<vector<ll>> dp(n,vector<ll>(k+1,-1e18));
    dp[0][0]=0;
    dp[0][1]=v[0];
    for(int i=1;i<n;i++){
        dp[i][0]=0;
        for(int j = 1;j <= (i/2 + 1);j++){
            ll l = 0;
            if(i>1) l = dp[i-2][j-1];
            dp[i][j] = max(dp[i-1][j], l + v[i]);
        }
    }
    /*for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            cout<<dp[i][j]<<' ';
        }
        cout<<endl;
    }*/
    for(int i=1;i<=k;i++) cout<<dp[n-1][i]<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 16216 KB Output is correct
2 Correct 9 ms 16220 KB Output is correct
3 Correct 9 ms 16236 KB Output is correct
4 Correct 9 ms 16112 KB Output is correct
5 Correct 9 ms 16220 KB Output is correct
6 Correct 9 ms 16236 KB Output is correct
7 Correct 9 ms 16080 KB Output is correct
8 Correct 9 ms 16220 KB Output is correct
9 Correct 10 ms 16048 KB Output is correct
10 Correct 9 ms 16216 KB Output is correct
11 Correct 9 ms 16220 KB Output is correct
12 Correct 9 ms 16216 KB Output is correct
13 Correct 9 ms 16220 KB Output is correct
14 Correct 9 ms 16216 KB Output is correct
15 Correct 8 ms 16220 KB Output is correct
16 Correct 9 ms 16024 KB Output is correct
17 Correct 9 ms 16220 KB Output is correct
18 Correct 9 ms 16096 KB Output is correct
19 Correct 9 ms 16216 KB Output is correct
20 Correct 10 ms 16220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 16216 KB Output is correct
2 Correct 9 ms 16220 KB Output is correct
3 Correct 9 ms 16236 KB Output is correct
4 Correct 9 ms 16112 KB Output is correct
5 Correct 9 ms 16220 KB Output is correct
6 Correct 9 ms 16236 KB Output is correct
7 Correct 9 ms 16080 KB Output is correct
8 Correct 9 ms 16220 KB Output is correct
9 Correct 10 ms 16048 KB Output is correct
10 Correct 9 ms 16216 KB Output is correct
11 Correct 9 ms 16220 KB Output is correct
12 Correct 9 ms 16216 KB Output is correct
13 Correct 9 ms 16220 KB Output is correct
14 Correct 9 ms 16216 KB Output is correct
15 Correct 8 ms 16220 KB Output is correct
16 Correct 9 ms 16024 KB Output is correct
17 Correct 9 ms 16220 KB Output is correct
18 Correct 9 ms 16096 KB Output is correct
19 Correct 9 ms 16216 KB Output is correct
20 Correct 10 ms 16220 KB Output is correct
21 Runtime error 201 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -