Submission #647811

# Submission time Handle Problem Language Result Execution time Memory
647811 2022-10-04T08:03:02 Z ymm Rabbit Carrot (LMIO19_triusis) C++17
100 / 100
40 ms 5444 KB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

const int N = 200'010;

int fen[N];
void up(int i, int x)
{
	++i;
	while (i < N) {
		fen[i] = min(fen[i], x);
		i += i & -i;
	}
}
int get(int r)
{
	int ans = N;
	while (r) {
		ans = min(ans, fen[r]);
		r -= r & -r;
	}
	return ans;
}

int dp[N];

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	int n, jmp;
	cin >> n >> jmp;
	vector<pii> vec;
	vec.push_back({-jmp*(n+1), ~(n+1)});
	Loop (i,1,n+1) {
		int x;
		cin >> x;
		if (x-jmp*i <= 0)
			vec.push_back({x-jmp*i, ~i});
	}
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	fill(dp, dp+N, N);
	fill(fen, fen+N, N);
	dp[0] = 0;
	up(0, 0);
	for (auto [_, i] : vec) {
		i = ~i;
		dp[i] = get(i) + i - 1;
		up(i, dp[i] - i);
	}
	cout << dp[n+1] << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Correct 2 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 2 ms 1876 KB Output is correct
8 Correct 2 ms 1860 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 2 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1860 KB Output is correct
15 Correct 1 ms 1876 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Correct 2 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 2 ms 1876 KB Output is correct
8 Correct 2 ms 1860 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 2 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1860 KB Output is correct
15 Correct 1 ms 1876 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 2 ms 1876 KB Output is correct
18 Correct 2 ms 1876 KB Output is correct
19 Correct 2 ms 1876 KB Output is correct
20 Correct 2 ms 1872 KB Output is correct
21 Correct 2 ms 2004 KB Output is correct
22 Correct 2 ms 1880 KB Output is correct
23 Correct 2 ms 2004 KB Output is correct
24 Correct 2 ms 1996 KB Output is correct
25 Correct 2 ms 2004 KB Output is correct
26 Correct 3 ms 2024 KB Output is correct
27 Correct 3 ms 1876 KB Output is correct
28 Correct 2 ms 2004 KB Output is correct
29 Correct 2 ms 2004 KB Output is correct
30 Correct 2 ms 2004 KB Output is correct
31 Correct 3 ms 2004 KB Output is correct
32 Correct 3 ms 2004 KB Output is correct
33 Correct 2 ms 2004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Correct 2 ms 1876 KB Output is correct
3 Correct 2 ms 1876 KB Output is correct
4 Correct 2 ms 1872 KB Output is correct
5 Correct 2 ms 2004 KB Output is correct
6 Correct 2 ms 1880 KB Output is correct
7 Correct 2 ms 2004 KB Output is correct
8 Correct 2 ms 1996 KB Output is correct
9 Correct 2 ms 2004 KB Output is correct
10 Correct 3 ms 2024 KB Output is correct
11 Correct 3 ms 1876 KB Output is correct
12 Correct 2 ms 2004 KB Output is correct
13 Correct 2 ms 2004 KB Output is correct
14 Correct 2 ms 2004 KB Output is correct
15 Correct 3 ms 2004 KB Output is correct
16 Correct 3 ms 2004 KB Output is correct
17 Correct 2 ms 2004 KB Output is correct
18 Correct 2 ms 1876 KB Output is correct
19 Correct 2 ms 1876 KB Output is correct
20 Correct 1 ms 1876 KB Output is correct
21 Correct 1 ms 1876 KB Output is correct
22 Correct 1 ms 1876 KB Output is correct
23 Correct 1 ms 1876 KB Output is correct
24 Correct 2 ms 1876 KB Output is correct
25 Correct 2 ms 1860 KB Output is correct
26 Correct 1 ms 1876 KB Output is correct
27 Correct 2 ms 1876 KB Output is correct
28 Correct 1 ms 1876 KB Output is correct
29 Correct 1 ms 1876 KB Output is correct
30 Correct 1 ms 1876 KB Output is correct
31 Correct 1 ms 1860 KB Output is correct
32 Correct 1 ms 1876 KB Output is correct
33 Correct 1 ms 1876 KB Output is correct
34 Correct 2 ms 1876 KB Output is correct
35 Correct 2 ms 1876 KB Output is correct
36 Correct 2 ms 1876 KB Output is correct
37 Correct 2 ms 2004 KB Output is correct
38 Correct 2 ms 1984 KB Output is correct
39 Correct 2 ms 2004 KB Output is correct
40 Correct 2 ms 2024 KB Output is correct
41 Correct 2 ms 1876 KB Output is correct
42 Correct 2 ms 2004 KB Output is correct
43 Correct 3 ms 2004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Correct 2 ms 1876 KB Output is correct
3 Correct 2 ms 1876 KB Output is correct
4 Correct 2 ms 2004 KB Output is correct
5 Correct 2 ms 1984 KB Output is correct
6 Correct 2 ms 2004 KB Output is correct
7 Correct 2 ms 2024 KB Output is correct
8 Correct 2 ms 1876 KB Output is correct
9 Correct 2 ms 2004 KB Output is correct
10 Correct 3 ms 2004 KB Output is correct
11 Correct 2 ms 1876 KB Output is correct
12 Correct 2 ms 1876 KB Output is correct
13 Correct 2 ms 1876 KB Output is correct
14 Correct 2 ms 1872 KB Output is correct
15 Correct 2 ms 2004 KB Output is correct
16 Correct 2 ms 1880 KB Output is correct
17 Correct 2 ms 2004 KB Output is correct
18 Correct 2 ms 1996 KB Output is correct
19 Correct 2 ms 2004 KB Output is correct
20 Correct 3 ms 2024 KB Output is correct
21 Correct 3 ms 1876 KB Output is correct
22 Correct 2 ms 2004 KB Output is correct
23 Correct 2 ms 2004 KB Output is correct
24 Correct 2 ms 2004 KB Output is correct
25 Correct 3 ms 2004 KB Output is correct
26 Correct 3 ms 2004 KB Output is correct
27 Correct 2 ms 2004 KB Output is correct
28 Correct 2 ms 1876 KB Output is correct
29 Correct 2 ms 1876 KB Output is correct
30 Correct 1 ms 1876 KB Output is correct
31 Correct 1 ms 1876 KB Output is correct
32 Correct 1 ms 1876 KB Output is correct
33 Correct 1 ms 1876 KB Output is correct
34 Correct 2 ms 1876 KB Output is correct
35 Correct 2 ms 1860 KB Output is correct
36 Correct 1 ms 1876 KB Output is correct
37 Correct 2 ms 1876 KB Output is correct
38 Correct 1 ms 1876 KB Output is correct
39 Correct 1 ms 1876 KB Output is correct
40 Correct 1 ms 1876 KB Output is correct
41 Correct 1 ms 1860 KB Output is correct
42 Correct 1 ms 1876 KB Output is correct
43 Correct 1 ms 1876 KB Output is correct
44 Correct 23 ms 3980 KB Output is correct
45 Correct 24 ms 3788 KB Output is correct
46 Correct 37 ms 4608 KB Output is correct
47 Correct 35 ms 4640 KB Output is correct
48 Correct 26 ms 4468 KB Output is correct
49 Correct 27 ms 4676 KB Output is correct
50 Correct 38 ms 5104 KB Output is correct
51 Correct 35 ms 5444 KB Output is correct
52 Correct 40 ms 4432 KB Output is correct
53 Correct 26 ms 3108 KB Output is correct
54 Correct 34 ms 4612 KB Output is correct
55 Correct 28 ms 4544 KB Output is correct