Submission #101134

# Submission time Handle Problem Language Result Execution time Memory
101134 2019-03-17T01:49:03 Z TAISA_ Candies (JOI18_candies) C++14
8 / 100
75 ms 63356 KB
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll MOD=1000000007LL;
const ll INF=(1<<30);
const ll LINF=(1LL<<60);
template<typename T> void chmax(T &a,T b){a=max(a,b);}
template<typename T> void chmin(T &a,T b){a=min(a,b);} 
ll dp[2010][2010][2];
int main(){
    int n;cin>>n;if(n>2000)return 0;
    vector<ll> a(n+10);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)for(int k=0;k<2;k++)dp[i][j][k]=-LINF;
	dp[0][0][0]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j)chmax(dp[i][j][1],dp[i-1][j-1][0]+a[i]);
			chmax(dp[i][j][0],dp[i-1][j][1]);
			chmax(dp[i][j][0],dp[i-1][j][0]);
		}
	}
	for(int i=1;i<=n/2+n%2;i++){
		cout<<max(dp[n][i][0],dp[n][i][1])<<endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 65 ms 63352 KB Output is correct
2 Correct 62 ms 63352 KB Output is correct
3 Correct 63 ms 63352 KB Output is correct
4 Correct 57 ms 63352 KB Output is correct
5 Correct 69 ms 63324 KB Output is correct
6 Correct 56 ms 63352 KB Output is correct
7 Correct 57 ms 63356 KB Output is correct
8 Correct 66 ms 63352 KB Output is correct
9 Correct 73 ms 63352 KB Output is correct
10 Correct 56 ms 63352 KB Output is correct
11 Correct 61 ms 63224 KB Output is correct
12 Correct 61 ms 63352 KB Output is correct
13 Correct 61 ms 63232 KB Output is correct
14 Correct 62 ms 63224 KB Output is correct
15 Correct 59 ms 63224 KB Output is correct
16 Correct 60 ms 63352 KB Output is correct
17 Correct 75 ms 63224 KB Output is correct
18 Correct 57 ms 63232 KB Output is correct
19 Correct 58 ms 63228 KB Output is correct
20 Correct 60 ms 63352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 63352 KB Output is correct
2 Correct 62 ms 63352 KB Output is correct
3 Correct 63 ms 63352 KB Output is correct
4 Correct 57 ms 63352 KB Output is correct
5 Correct 69 ms 63324 KB Output is correct
6 Correct 56 ms 63352 KB Output is correct
7 Correct 57 ms 63356 KB Output is correct
8 Correct 66 ms 63352 KB Output is correct
9 Correct 73 ms 63352 KB Output is correct
10 Correct 56 ms 63352 KB Output is correct
11 Correct 61 ms 63224 KB Output is correct
12 Correct 61 ms 63352 KB Output is correct
13 Correct 61 ms 63232 KB Output is correct
14 Correct 62 ms 63224 KB Output is correct
15 Correct 59 ms 63224 KB Output is correct
16 Correct 60 ms 63352 KB Output is correct
17 Correct 75 ms 63224 KB Output is correct
18 Correct 57 ms 63232 KB Output is correct
19 Correct 58 ms 63228 KB Output is correct
20 Correct 60 ms 63352 KB Output is correct
21 Incorrect 3 ms 256 KB Output isn't correct
22 Halted 0 ms 0 KB -