Submission #383169

# Submission time Handle Problem Language Result Execution time Memory
383169 2021-03-29T02:58:28 Z MODDI Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
2 ms 1152 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
int n, k;
int dp[200020], arr[200020];
int f(int at, int cur){
	if(at >= n)
		return 0;
	if(dp[at] != -1)
		return dp[at];
		
	int rez = 1e9;
	if(cur < arr[at + 1])
	{
		if(arr[at + 1] - cur <= k)
			rez = min(rez, f(at + 1, arr[at + 1]));
		else
			rez = min(rez, f(at + 1, cur + k) + 1);
	}
	else
		rez = min(rez, f(at + 1, arr[at + 1]));
		
	return dp[at] = rez;
}
int main(){
	cin>>n>>k;
	for(int i = 0; i < n; i++){
		cin>>arr[i + 1];
	}
	arr[0] = 0;
	memset(dp,-1,sizeof(dp));
	int add = 0;
	if(arr[1] > k)
	{
		arr[1] = k;
		add++;
	}
	cout<<f(1, k) + add<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1152 KB Output is correct
2 Correct 1 ms 1132 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 2 ms 1132 KB Output is correct
5 Correct 2 ms 1132 KB Output is correct
6 Correct 1 ms 1132 KB Output is correct
7 Correct 1 ms 1132 KB Output is correct
8 Incorrect 1 ms 1132 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1152 KB Output is correct
2 Correct 1 ms 1132 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 2 ms 1132 KB Output is correct
5 Correct 2 ms 1132 KB Output is correct
6 Correct 1 ms 1132 KB Output is correct
7 Correct 1 ms 1132 KB Output is correct
8 Incorrect 1 ms 1132 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1152 KB Output is correct
2 Correct 1 ms 1132 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 2 ms 1132 KB Output is correct
5 Correct 2 ms 1132 KB Output is correct
6 Correct 1 ms 1132 KB Output is correct
7 Correct 1 ms 1132 KB Output is correct
8 Incorrect 1 ms 1132 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1152 KB Output is correct
2 Correct 1 ms 1132 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 2 ms 1132 KB Output is correct
5 Correct 2 ms 1132 KB Output is correct
6 Correct 1 ms 1132 KB Output is correct
7 Correct 1 ms 1132 KB Output is correct
8 Incorrect 1 ms 1132 KB Output isn't correct
9 Halted 0 ms 0 KB -