#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
ll mod=(ll)1e9+7;
ll mod1=998244353;
///the defines :)
#define endl '\n'
#define vi vector<int>
#define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
#define all(arr) arr.begin(),arr.end()
#define allr(arr) arr.rbegin(),arr.rend()
#define sz size()
#define int long long
int n,d,a;
vi arr;
int dp[600][600];
void preprocess() {}
void solve()
{
cin>>n>>d>>a;
arr.resize(n);
ent(arr);
for(int i=0;i<=n;i++)for(int j=0;j<=d+1;j++)dp[i][j]=1e9;
dp[n][0]=0;
for(int i=n-1; i>=0; i--)
{
// dp[i][0]=0;
for(int j=1; j<=d+1; j++)
{
int cnt=0,lol=arr[i];
for(int k=i+1; k<=n; k++)
{
cnt+=(lol<=a);
//cout<<i<<" "<<j<<" "<<k<<" "<<cnt<<endl;
dp[i][j]=min(dp[i][j],dp[k][j-1]+cnt);
lol=min(arr[k],lol+1);
}
}
}
cout<<dp[0][d+1];
}
signed main()
{
// freopen("meta_game_input.txt","r",stdin);
// freopen("otput.txt","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
preprocess();
//bla();
int t=1;
//cin>>t;
while(t--)
solve();
}
Compilation message
prison.cpp: In function 'void solve()':
prison.cpp:14:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | #define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
| ~^~~~~~~~~~~
prison.cpp:27:5: note: in expansion of macro 'ent'
27 | ent(arr);
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
2512 KB |
Output is correct |
3 |
Correct |
4 ms |
2648 KB |
Output is correct |
4 |
Correct |
14 ms |
3164 KB |
Output is correct |
5 |
Correct |
24 ms |
2824 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
11 ms |
2648 KB |
Output is correct |
8 |
Correct |
3 ms |
2648 KB |
Output is correct |
9 |
Correct |
6 ms |
2652 KB |
Output is correct |
10 |
Correct |
13 ms |
2648 KB |
Output is correct |
11 |
Correct |
24 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Runtime error |
44 ms |
18772 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
2512 KB |
Output is correct |
3 |
Correct |
4 ms |
2648 KB |
Output is correct |
4 |
Correct |
14 ms |
3164 KB |
Output is correct |
5 |
Correct |
24 ms |
2824 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
11 ms |
2648 KB |
Output is correct |
8 |
Correct |
3 ms |
2648 KB |
Output is correct |
9 |
Correct |
6 ms |
2652 KB |
Output is correct |
10 |
Correct |
13 ms |
2648 KB |
Output is correct |
11 |
Correct |
24 ms |
2652 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
2652 KB |
Output is correct |
14 |
Correct |
4 ms |
2652 KB |
Output is correct |
15 |
Correct |
13 ms |
2796 KB |
Output is correct |
16 |
Correct |
24 ms |
2652 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
11 ms |
2652 KB |
Output is correct |
19 |
Correct |
3 ms |
2648 KB |
Output is correct |
20 |
Correct |
6 ms |
2648 KB |
Output is correct |
21 |
Correct |
12 ms |
2652 KB |
Output is correct |
22 |
Correct |
25 ms |
2652 KB |
Output is correct |
23 |
Runtime error |
4 ms |
6236 KB |
Execution killed with signal 11 |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Runtime error |
10 ms |
8024 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
2512 KB |
Output is correct |
3 |
Correct |
4 ms |
2648 KB |
Output is correct |
4 |
Correct |
14 ms |
3164 KB |
Output is correct |
5 |
Correct |
24 ms |
2824 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
11 ms |
2648 KB |
Output is correct |
8 |
Correct |
3 ms |
2648 KB |
Output is correct |
9 |
Correct |
6 ms |
2652 KB |
Output is correct |
10 |
Correct |
13 ms |
2648 KB |
Output is correct |
11 |
Correct |
24 ms |
2652 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
2652 KB |
Output is correct |
14 |
Correct |
4 ms |
2652 KB |
Output is correct |
15 |
Correct |
13 ms |
2796 KB |
Output is correct |
16 |
Correct |
24 ms |
2652 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
11 ms |
2652 KB |
Output is correct |
19 |
Correct |
3 ms |
2648 KB |
Output is correct |
20 |
Correct |
6 ms |
2648 KB |
Output is correct |
21 |
Correct |
12 ms |
2652 KB |
Output is correct |
22 |
Correct |
25 ms |
2652 KB |
Output is correct |
23 |
Runtime error |
4 ms |
6236 KB |
Execution killed with signal 11 |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
2512 KB |
Output is correct |
3 |
Correct |
4 ms |
2648 KB |
Output is correct |
4 |
Correct |
14 ms |
3164 KB |
Output is correct |
5 |
Correct |
24 ms |
2824 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
11 ms |
2648 KB |
Output is correct |
8 |
Correct |
3 ms |
2648 KB |
Output is correct |
9 |
Correct |
6 ms |
2652 KB |
Output is correct |
10 |
Correct |
13 ms |
2648 KB |
Output is correct |
11 |
Correct |
24 ms |
2652 KB |
Output is correct |
12 |
Correct |
1 ms |
600 KB |
Output is correct |
13 |
Runtime error |
44 ms |
18772 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |