Submission #62605

# Submission time Handle Problem Language Result Execution time Memory
62605 2018-07-29T10:03:05 Z gusfring Candies (JOI18_candies) C++14
8 / 100
23 ms 12512 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=1; 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 Correct 20 ms 11768 KB Output is correct
2 Correct 21 ms 11880 KB Output is correct
3 Correct 17 ms 11880 KB Output is correct
4 Correct 18 ms 12048 KB Output is correct
5 Correct 17 ms 12048 KB Output is correct
6 Correct 20 ms 12192 KB Output is correct
7 Correct 19 ms 12212 KB Output is correct
8 Correct 20 ms 12292 KB Output is correct
9 Correct 22 ms 12292 KB Output is correct
10 Correct 18 ms 12292 KB Output is correct
11 Correct 23 ms 12292 KB Output is correct
12 Correct 18 ms 12292 KB Output is correct
13 Correct 22 ms 12292 KB Output is correct
14 Correct 21 ms 12292 KB Output is correct
15 Correct 21 ms 12312 KB Output is correct
16 Correct 18 ms 12324 KB Output is correct
17 Correct 19 ms 12512 KB Output is correct
18 Correct 20 ms 12512 KB Output is correct
19 Correct 17 ms 12512 KB Output is correct
20 Correct 22 ms 12512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 11768 KB Output is correct
2 Correct 21 ms 11880 KB Output is correct
3 Correct 17 ms 11880 KB Output is correct
4 Correct 18 ms 12048 KB Output is correct
5 Correct 17 ms 12048 KB Output is correct
6 Correct 20 ms 12192 KB Output is correct
7 Correct 19 ms 12212 KB Output is correct
8 Correct 20 ms 12292 KB Output is correct
9 Correct 22 ms 12292 KB Output is correct
10 Correct 18 ms 12292 KB Output is correct
11 Correct 23 ms 12292 KB Output is correct
12 Correct 18 ms 12292 KB Output is correct
13 Correct 22 ms 12292 KB Output is correct
14 Correct 21 ms 12292 KB Output is correct
15 Correct 21 ms 12312 KB Output is correct
16 Correct 18 ms 12324 KB Output is correct
17 Correct 19 ms 12512 KB Output is correct
18 Correct 20 ms 12512 KB Output is correct
19 Correct 17 ms 12512 KB Output is correct
20 Correct 22 ms 12512 KB Output is correct
21 Execution timed out 5 ms 12512 KB Time limit exceeded (wall clock)
22 Halted 0 ms 0 KB -