# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
798828 |
2023-07-31T04:52:36 Z |
vjudge1 |
Candies (JOI18_candies) |
C++14 |
|
685 ms |
24156 KB |
#include<bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std ;
const ll N = 1e5, NS = 2e3 ;
ll n, a[N + 1], ans[NS + 1], dp[NS + 1][NS + 1][2] ;
signed main()
{
ios_base::sync_with_stdio( 0 ) ;
cin.tie( 0 ) ;
cout.tie( 0 ) ;
cin >> n ;
for(ll i = 1 ; i <= n ; i++)
cin >> a[i] ;
if(n <= 2000)
{
for(ll i = 1 ; i <= n ; i++)
for(ll j = 1 ; j <= (i + 1) / 2 ; j++)
{
dp[i][j][0] = max(dp[i - 1][j][0], dp[i - 1][j][1]) ;
dp[i][j][1] = dp[i - 1][j - 1][0] + a[i] ;
ans[j] = max({ans[j], dp[i][j][0], dp[i][j][1]}) ;
}
// for(ll i = 1 ; i <= n ; i++)
// for(ll j = 1 ; j <= i ; j++)
// cout<<i<<' '<<j<<' '<<dp[i][j][0] << ' ' << dp[i][j][1] << '\n' ;
for(int i = 1 ; i <= (n + 1) / 2 ; i++)
cout << ans[i] << '\n' ;
return 0 ;
}
return 0 ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
24008 KB |
Output is correct |
2 |
Correct |
11 ms |
24024 KB |
Output is correct |
3 |
Correct |
11 ms |
24020 KB |
Output is correct |
4 |
Correct |
15 ms |
24156 KB |
Output is correct |
5 |
Correct |
11 ms |
24020 KB |
Output is correct |
6 |
Correct |
11 ms |
24020 KB |
Output is correct |
7 |
Correct |
11 ms |
24040 KB |
Output is correct |
8 |
Correct |
11 ms |
24020 KB |
Output is correct |
9 |
Correct |
11 ms |
24040 KB |
Output is correct |
10 |
Correct |
11 ms |
24020 KB |
Output is correct |
11 |
Correct |
10 ms |
24020 KB |
Output is correct |
12 |
Correct |
11 ms |
24076 KB |
Output is correct |
13 |
Correct |
11 ms |
24016 KB |
Output is correct |
14 |
Correct |
11 ms |
24112 KB |
Output is correct |
15 |
Correct |
11 ms |
24068 KB |
Output is correct |
16 |
Correct |
12 ms |
24020 KB |
Output is correct |
17 |
Correct |
11 ms |
24040 KB |
Output is correct |
18 |
Correct |
11 ms |
24020 KB |
Output is correct |
19 |
Correct |
11 ms |
24000 KB |
Output is correct |
20 |
Correct |
11 ms |
24020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
24008 KB |
Output is correct |
2 |
Correct |
11 ms |
24024 KB |
Output is correct |
3 |
Correct |
11 ms |
24020 KB |
Output is correct |
4 |
Correct |
15 ms |
24156 KB |
Output is correct |
5 |
Correct |
11 ms |
24020 KB |
Output is correct |
6 |
Correct |
11 ms |
24020 KB |
Output is correct |
7 |
Correct |
11 ms |
24040 KB |
Output is correct |
8 |
Correct |
11 ms |
24020 KB |
Output is correct |
9 |
Correct |
11 ms |
24040 KB |
Output is correct |
10 |
Correct |
11 ms |
24020 KB |
Output is correct |
11 |
Correct |
10 ms |
24020 KB |
Output is correct |
12 |
Correct |
11 ms |
24076 KB |
Output is correct |
13 |
Correct |
11 ms |
24016 KB |
Output is correct |
14 |
Correct |
11 ms |
24112 KB |
Output is correct |
15 |
Correct |
11 ms |
24068 KB |
Output is correct |
16 |
Correct |
12 ms |
24020 KB |
Output is correct |
17 |
Correct |
11 ms |
24040 KB |
Output is correct |
18 |
Correct |
11 ms |
24020 KB |
Output is correct |
19 |
Correct |
11 ms |
24000 KB |
Output is correct |
20 |
Correct |
11 ms |
24020 KB |
Output is correct |
21 |
Runtime error |
685 ms |
3128 KB |
Execution killed with signal 11 |
22 |
Halted |
0 ms |
0 KB |
- |