Submission #62604

# Submission time Handle Problem Language Result Execution time Memory
62604 2018-07-29T10:02:17 Z gusfring Candies (JOI18_candies) C++14
0 / 100
18 ms 11640 KB
#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

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 time Memory Grader output
1 Incorrect 18 ms 11640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 11640 KB Output isn't correct
2 Halted 0 ms 0 KB -