-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11058.cpp
More file actions
27 lines (23 loc) · 452 Bytes
/
11058.cpp
File metadata and controls
27 lines (23 loc) · 452 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;
int main(){
cin.tie(nullptr);
cout.tie(nullptr);
ios::sync_with_stdio(false);
ll N; cin >> N;
ll dp[1000];
dp[0] = 0;
dp[1] = 1;
dp[2] = 2;
dp[3] = 3;
for (int i = 3; i <= N; i++) {
dp[i] = dp[i - 1] + 1;
for (int j = 0; j <= i - 2; j++) {
dp[i] = max(dp[i], dp[j] * (i - j - 2) + dp[j]);
}
}
cout << dp[N];
return 0;
}