Submission #96724

# Submission time Handle Problem Language Result Execution time Memory
96724 2019-02-11T14:54:30 Z Retro3014 Candies (JOI18_candies) C++17
8 / 100
186 ms 69100 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>


using namespace std;
#define MAX_N 2000
#define INF 1000000000000000000LL
typedef long long ll;

int N;
vector<ll> v;
ll dp[MAX_N+10][MAX_N+10];

int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		ll x;
		scanf("%lld", &x); v.push_back(x);
	}
	for(int i=0; i<N; i++){
		for(int j=1; j<=((N+1)/2); j++){
			dp[i][j] = -INF;
		}
	}
	for(int i=0; i<N; i++){
		for(int j=1; j<=((i+2)/2); j++){
			if(i==0){
				dp[i][j] = v[i];
			}else if(i==1){
				dp[i][j] = max(v[0], v[1]);
			}else{
				dp[i][j] = max(dp[i-1][j], dp[i-2][j-1]+v[i]);
			}
		}
	}
	for(int i=1; i<=((N+1)/2); i++){
		printf("%lld\n", dp[N-1][i]);
	}
	return 0;
}

Compilation message

candies.cpp: In function 'int main()':
candies.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
candies.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &x); v.push_back(x);
   ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 22 ms 24184 KB Output is correct
2 Correct 21 ms 24056 KB Output is correct
3 Correct 26 ms 24024 KB Output is correct
4 Correct 22 ms 24056 KB Output is correct
5 Correct 21 ms 24056 KB Output is correct
6 Correct 21 ms 24056 KB Output is correct
7 Correct 22 ms 24184 KB Output is correct
8 Correct 21 ms 24056 KB Output is correct
9 Correct 21 ms 24056 KB Output is correct
10 Correct 22 ms 24060 KB Output is correct
11 Correct 19 ms 24056 KB Output is correct
12 Correct 21 ms 24052 KB Output is correct
13 Correct 21 ms 24056 KB Output is correct
14 Correct 26 ms 24056 KB Output is correct
15 Correct 20 ms 24056 KB Output is correct
16 Correct 19 ms 24056 KB Output is correct
17 Correct 22 ms 24056 KB Output is correct
18 Correct 22 ms 24024 KB Output is correct
19 Correct 21 ms 24056 KB Output is correct
20 Correct 21 ms 24056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 24184 KB Output is correct
2 Correct 21 ms 24056 KB Output is correct
3 Correct 26 ms 24024 KB Output is correct
4 Correct 22 ms 24056 KB Output is correct
5 Correct 21 ms 24056 KB Output is correct
6 Correct 21 ms 24056 KB Output is correct
7 Correct 22 ms 24184 KB Output is correct
8 Correct 21 ms 24056 KB Output is correct
9 Correct 21 ms 24056 KB Output is correct
10 Correct 22 ms 24060 KB Output is correct
11 Correct 19 ms 24056 KB Output is correct
12 Correct 21 ms 24052 KB Output is correct
13 Correct 21 ms 24056 KB Output is correct
14 Correct 26 ms 24056 KB Output is correct
15 Correct 20 ms 24056 KB Output is correct
16 Correct 19 ms 24056 KB Output is correct
17 Correct 22 ms 24056 KB Output is correct
18 Correct 22 ms 24024 KB Output is correct
19 Correct 21 ms 24056 KB Output is correct
20 Correct 21 ms 24056 KB Output is correct
21 Runtime error 186 ms 69100 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Halted 0 ms 0 KB -