답안 #869343

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
869343 2023-11-04T05:49:55 Z pi61 Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
2 ms 8648 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,k,a[200005],tree[800020], dp[200005];
void update(int pos, int val, int id=1, int l=1, int r=n)
{
	if (pos < l or r < pos) return;
	if (l==r)
	{
		tree[id]=val;
		return;
	}
	int mid=(l+r)/2;
	update(pos,val,id*2,l,mid);
	update(pos,val,id*2+1,mid+1,r);
	tree[id]=min(tree[id*2],tree[id*2+1]);
}
int get(int val, int id=1, int l=1, int r=n)
{
	if (tree[id] > val) return -1;
	if (l==r) return l;
	int mid=(l+r)/2;
	int L = get(val,id*2,l,mid);
	if (L != -1) return L;
	return get(val,id*2+1,mid+1,r);
}
signed main()
{
	fill(tree,tree+800000,1e6);
	cin>>n>>k;
	n+=2;
	for (int i = 2; i < n; i++) cin>>a[i];
	dp[n]=0;
	update(n,a[n]-n*k);
	for (int i = n-1; i > 0; i--)
	{
	//	for (int i = 1; i <= 4*n; i++) cout<<tree[i]<<' ';cout<<endl;
		int cur=get(a[i]-i*k);
		dp[i]=dp[cur]+cur-i-1;
		update(i,a[i]-i*k);
	//	cout<<cur<<' '<<dp[i]<<endl;
	}
	cout<<dp[1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 2 ms 8540 KB Output is correct
3 Correct 2 ms 8648 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 1 ms 8536 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 2 ms 8540 KB Output is correct
8 Correct 2 ms 8540 KB Output is correct
9 Correct 2 ms 8536 KB Output is correct
10 Correct 2 ms 8540 KB Output is correct
11 Correct 2 ms 8540 KB Output is correct
12 Incorrect 2 ms 8536 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 2 ms 8540 KB Output is correct
3 Correct 2 ms 8648 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 1 ms 8536 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 2 ms 8540 KB Output is correct
8 Correct 2 ms 8540 KB Output is correct
9 Correct 2 ms 8536 KB Output is correct
10 Correct 2 ms 8540 KB Output is correct
11 Correct 2 ms 8540 KB Output is correct
12 Incorrect 2 ms 8536 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 2 ms 8540 KB Output is correct
3 Correct 2 ms 8648 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 1 ms 8536 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 2 ms 8540 KB Output is correct
8 Correct 2 ms 8540 KB Output is correct
9 Correct 2 ms 8536 KB Output is correct
10 Correct 2 ms 8540 KB Output is correct
11 Correct 2 ms 8540 KB Output is correct
12 Incorrect 2 ms 8536 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 2 ms 8540 KB Output is correct
3 Correct 2 ms 8648 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 1 ms 8536 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 2 ms 8540 KB Output is correct
8 Correct 2 ms 8540 KB Output is correct
9 Correct 2 ms 8536 KB Output is correct
10 Correct 2 ms 8540 KB Output is correct
11 Correct 2 ms 8540 KB Output is correct
12 Incorrect 2 ms 8536 KB Output isn't correct
13 Halted 0 ms 0 KB -