# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
410037 | levsog2004 | Fun Tour (APIO20_fun) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
#define all(x) x.begin(),x.end()
#define se second
#define fr first
#define m_p make_pair
using namespace std;
typedef int ll;
const ll N = 1000004;
const ll inf = 1000 * 1000 * 100 + 7;
//const ll oo = 1000 * 1000 * 1000000;
ll n, m, k, u, x,s, r, y,q, z, pat, mx,ans,dp[3000][500];
int main()
{
cin >> n >> k;
for (int i = 0; i < 3000; i++)
for (int j = 0; j < 70; j++)
dp[i][j] = inf;
for (int i = 1; i < 2001; i++)
dp[i][1] = i-1;
for (int i = 1; i < 61; i++)
dp[1][i] = 0;
for (int i = 2; i <= n; i++)
{
for (int j = 2; j < k + 1; j++)
{
for (int u = 1; u <= i; u++)
dp[i][j] = min(dp[i][j], max(dp[u][j - 1], dp[i - u][j])+1);
}
}
cout << dp[n][k] << endl;
return 0;
}