Submission #503513

# Submission time Handle Problem Language Result Execution time Memory
503513 2022-01-08T09:06:54 Z Koosha_mv Candies (JOI18_candies) C++14
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#define int ll

const int N=1111,inf=1e10;

int n,t,a[N],dp[N][N];

main(){
	srand(time(NULL));
	cin>>n;
	f(i,1,n+1){
		cin>>a[i];
		//a[i]=rand()%100;
		//cout<<a[i]<<" ";
	}
	f(i,0,N) f(j,1,N) dp[i][j]=-inf;
	dp[1][1]=a[1];
	f(i,2,n+1){
		f(j,1,n+1){
			dp[i][j]=max(dp[i-1][j],dp[i-2][j-1]+a[i]);
		}
	}
	f(i,1,(n+1)/2+1){
		cout<<dp[n][i]<<" ";
	}
}

Compilation message

candies.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   28 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -