Submission #503515

#TimeUsernameProblemLanguageResultExecution timeMemory
503515Koosha_mvCandies (JOI18_candies)C++14
8 / 100
101 ms241988 KiB
#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=5555,inf=1e16; 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 (stderr)

candies.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   28 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...