답안 #274231

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
274231 2020-08-19T10:11:36 Z Halit Candies (JOI18_candies) C++17
0 / 100
105 ms 32248 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	
	vector<long long> v;
	for(int i = 0;i < n;++i){
		long long c;
		scanf("%lld", &c);
		v.push_back(c);
	}

	vector< vector<long long> > dp(n+5, vector<long long>(n+5,-1));
	function<long long(int, int)> DP = [&](int i, int j) -> long long{
		if(i >= n || j <= 0) return (j > 0 ? -2 : 0);
		if(dp[i][j] != -1)
			return dp[i][j];
	
		long long d = DP(i+1,j);
		if(j > 0)
			d = max(DP(i+2, j-1) + v[i], d);
		return dp[i][j] = d;
	};
	
	for(int i = 1;i <= (n+1)/2;++i)
		printf("%lld\n", DP(0,i));
}

Compilation message

candies.cpp: In function 'int main()':
candies.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    6 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
candies.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |   scanf("%lld", &c);
      |   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 105 ms 32248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 105 ms 32248 KB Output isn't correct
2 Halted 0 ms 0 KB -