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<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[502][502];
void preprocess() {}
void solve()
{
cin>>n>>d>>a;
arr.resize(n+1);
for(int i=1; i<=n; i++)
cin>>arr[i];
for(int i=0;i<=n;i++)for(int j=0;j<=d;j++)dp[i][j]=1e9;
dp[n][0]=0;
for(int i=n; i>=1; i--)
{
// dp[i][0]=0;
for(int j=1; j<=d; j++)
{
int cnt=0,lol=arr[i];
for(int k=i+1; k<=n; k++)
{
lol++;
cnt+=(min(arr[k],lol)<=a);
dp[i][j]=min(dp[i][j],dp[k][j-1]+cnt);
}
}
}
cout<<dp[1][d]<<endl;
}
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();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |