Submission #62604

#TimeUsernameProblemLanguageResultExecution timeMemory
62604gusfringCandies (JOI18_candies)C++14
0 / 100
18 ms11640 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e3 + 5; typedef long long ll; int N, A[MAXN]; long long dp[MAXN][MAXN]; int main(){ scanf("%d", &N); for(int i=1; i<=N; ++i){ scanf("%d", &A[i]); dp[1][i] = max(dp[1][i - 1], 1LL * A[i]); } for(int k=2; k<=(N+1)/2; ++k) for(int i=2*k-1; i<=N; ++i) dp[k][i] = max(dp[k - 1][i - 2] + A[i], dp[k][i - 1]); for(int k=2; k<=(N+1)/2; ++k) printf("%lld ", dp[k][N]); return 0; }

Compilation message (stderr)

candies.cpp: In function 'int main()':
candies.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
candies.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &A[i]);
   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...