답안 #967505

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967505 2024-04-22T09:32:59 Z Tuanlinh123 Candies (JOI18_candies) C++17
8 / 100
12 ms 31900 KB
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
#define sz(a) ((ll)(a).size())
using namespace std;

const ll maxn=2005, inf=1e18;
ll a[maxn], dp[maxn][maxn];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n; cin >> n;
    for (ll i=1; i<=n; i++) cin >> a[i];
    for (ll i=0; i<=n; i++)
        for (ll j=1; j<=n; j++)
        {
            if (i==0) dp[i][j]=-inf;
            else if (i==1) dp[i][j]=j==1?a[i]:-inf;
            else dp[i][j]=max(dp[i-1][j], dp[i-2][j-1]+a[i]);
        }
    for (ll i=1; i<=(n+1)/2; i++) cout << dp[n][i] << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31832 KB Output is correct
2 Correct 8 ms 31836 KB Output is correct
3 Correct 9 ms 31836 KB Output is correct
4 Correct 8 ms 31832 KB Output is correct
5 Correct 8 ms 31836 KB Output is correct
6 Correct 8 ms 31836 KB Output is correct
7 Correct 9 ms 31836 KB Output is correct
8 Correct 8 ms 31836 KB Output is correct
9 Correct 8 ms 31836 KB Output is correct
10 Correct 8 ms 31836 KB Output is correct
11 Correct 8 ms 31836 KB Output is correct
12 Correct 9 ms 31900 KB Output is correct
13 Correct 8 ms 31836 KB Output is correct
14 Correct 8 ms 31832 KB Output is correct
15 Correct 8 ms 31836 KB Output is correct
16 Correct 8 ms 31832 KB Output is correct
17 Correct 8 ms 31836 KB Output is correct
18 Correct 8 ms 31836 KB Output is correct
19 Correct 8 ms 31836 KB Output is correct
20 Correct 8 ms 31836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31832 KB Output is correct
2 Correct 8 ms 31836 KB Output is correct
3 Correct 9 ms 31836 KB Output is correct
4 Correct 8 ms 31832 KB Output is correct
5 Correct 8 ms 31836 KB Output is correct
6 Correct 8 ms 31836 KB Output is correct
7 Correct 9 ms 31836 KB Output is correct
8 Correct 8 ms 31836 KB Output is correct
9 Correct 8 ms 31836 KB Output is correct
10 Correct 8 ms 31836 KB Output is correct
11 Correct 8 ms 31836 KB Output is correct
12 Correct 9 ms 31900 KB Output is correct
13 Correct 8 ms 31836 KB Output is correct
14 Correct 8 ms 31832 KB Output is correct
15 Correct 8 ms 31836 KB Output is correct
16 Correct 8 ms 31832 KB Output is correct
17 Correct 8 ms 31836 KB Output is correct
18 Correct 8 ms 31836 KB Output is correct
19 Correct 8 ms 31836 KB Output is correct
20 Correct 8 ms 31836 KB Output is correct
21 Runtime error 2 ms 604 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -