| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1330467 | Nika533 | Candies (JOI18_candies) | C++17 | 134 ms | 33404 KiB |
#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define flush fflush(stdout)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pii pair<int,int>
using namespace std;
int n,m,T,k;
int dp[2005][2005];
void test_case() {
cin>>n;
int arr[n+1];
for (int i=1; i<=n; i++) {
cin>>arr[i];
for (int j=1; j<=(i+1)/2; j++) {
if (i==1) dp[i][j]=arr[i];
else dp[i][j]=max(dp[i-1][j],dp[i-2][j-1]+arr[i]);
}
for (int j=(i+1)/2+1; j<=n; j++) {
dp[i][j]=-1e18;
}
if (i==n) {
for (int j=1; j<=(n+1)/2; j++) cout<<dp[i][j]<<endl;
}
}
}
main () {
ios :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
T=1;
while (T--) test_case();
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
