#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
typedef tree < pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
bool cmp(pair<int, int>& a, pair<int, int>& b) { return a.second < b.second; }
#define ll long long
#define mod 1000000007
#define mod2 99824435
const int INF = (int)1e9;
int add(int i, int j) {
if ((i += j) >= mod)
i -= mod;
return i;
}
int sub(int i, int j) {
if ((i -= j) < 0)
i += mod;
return i;
}
const int MAXN = 201010;
const int N = 3e5+10;
vector<int>adj[N];
vector<int> st, en;
vector<vector<int>>up;
const int maxn = 1000;
int longest_nondec_subseq(const vector<int>& seq) {
vector<int> mine;
for (int i : seq) {
int pos = std::upper_bound(mine.begin(), mine.end(), i) - mine.begin();
if (pos == mine.size()) {
mine.push_back(i);
} else {
mine[pos] = i;
}
}
return mine.size();
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("herding.in","r",stdin);
//freopen("herding.out","w",stdout);
//set<int, greater<int>>st;
//
int pole_num;
int jump_height;
std::cin >> pole_num >> jump_height;
vector<int> poles(pole_num);
for (int p = 0; p < pole_num; p++) {
std::cin >> poles[p];
}
vector<int> poss;
for (int i = 1; i <= pole_num; i++) {
if (i * jump_height >= poles[i - 1]) {
poss.push_back(i * jump_height - poles[i - 1]);
}
}
cout << pole_num - longest_nondec_subseq(poss) << endl;
return 0;
}
Compilation message
triusis.cpp: In function 'int longest_nondec_subseq(const std::vector<int>&)':
triusis.cpp:34:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | if (pos == mine.size()) {
| ~~~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7296 KB |
Output is correct |
2 |
Correct |
4 ms |
7364 KB |
Output is correct |
3 |
Correct |
4 ms |
7244 KB |
Output is correct |
4 |
Correct |
4 ms |
7244 KB |
Output is correct |
5 |
Correct |
5 ms |
7360 KB |
Output is correct |
6 |
Correct |
4 ms |
7244 KB |
Output is correct |
7 |
Correct |
4 ms |
7244 KB |
Output is correct |
8 |
Correct |
4 ms |
7244 KB |
Output is correct |
9 |
Correct |
4 ms |
7244 KB |
Output is correct |
10 |
Correct |
4 ms |
7360 KB |
Output is correct |
11 |
Correct |
4 ms |
7360 KB |
Output is correct |
12 |
Correct |
4 ms |
7360 KB |
Output is correct |
13 |
Correct |
4 ms |
7244 KB |
Output is correct |
14 |
Correct |
4 ms |
7356 KB |
Output is correct |
15 |
Correct |
6 ms |
7360 KB |
Output is correct |
16 |
Correct |
4 ms |
7344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7296 KB |
Output is correct |
2 |
Correct |
4 ms |
7364 KB |
Output is correct |
3 |
Correct |
4 ms |
7244 KB |
Output is correct |
4 |
Correct |
4 ms |
7244 KB |
Output is correct |
5 |
Correct |
5 ms |
7360 KB |
Output is correct |
6 |
Correct |
4 ms |
7244 KB |
Output is correct |
7 |
Correct |
4 ms |
7244 KB |
Output is correct |
8 |
Correct |
4 ms |
7244 KB |
Output is correct |
9 |
Correct |
4 ms |
7244 KB |
Output is correct |
10 |
Correct |
4 ms |
7360 KB |
Output is correct |
11 |
Correct |
4 ms |
7360 KB |
Output is correct |
12 |
Correct |
4 ms |
7360 KB |
Output is correct |
13 |
Correct |
4 ms |
7244 KB |
Output is correct |
14 |
Correct |
4 ms |
7356 KB |
Output is correct |
15 |
Correct |
6 ms |
7360 KB |
Output is correct |
16 |
Correct |
4 ms |
7344 KB |
Output is correct |
17 |
Correct |
4 ms |
7244 KB |
Output is correct |
18 |
Correct |
5 ms |
7356 KB |
Output is correct |
19 |
Correct |
4 ms |
7244 KB |
Output is correct |
20 |
Correct |
4 ms |
7372 KB |
Output is correct |
21 |
Correct |
4 ms |
7372 KB |
Output is correct |
22 |
Correct |
4 ms |
7368 KB |
Output is correct |
23 |
Correct |
5 ms |
7524 KB |
Output is correct |
24 |
Correct |
6 ms |
7368 KB |
Output is correct |
25 |
Correct |
4 ms |
7372 KB |
Output is correct |
26 |
Correct |
4 ms |
7372 KB |
Output is correct |
27 |
Correct |
4 ms |
7364 KB |
Output is correct |
28 |
Correct |
4 ms |
7376 KB |
Output is correct |
29 |
Correct |
5 ms |
7372 KB |
Output is correct |
30 |
Correct |
4 ms |
7372 KB |
Output is correct |
31 |
Correct |
5 ms |
7372 KB |
Output is correct |
32 |
Correct |
4 ms |
7372 KB |
Output is correct |
33 |
Correct |
5 ms |
7372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7244 KB |
Output is correct |
2 |
Correct |
5 ms |
7356 KB |
Output is correct |
3 |
Correct |
4 ms |
7244 KB |
Output is correct |
4 |
Correct |
4 ms |
7372 KB |
Output is correct |
5 |
Correct |
4 ms |
7372 KB |
Output is correct |
6 |
Correct |
4 ms |
7368 KB |
Output is correct |
7 |
Correct |
5 ms |
7524 KB |
Output is correct |
8 |
Correct |
6 ms |
7368 KB |
Output is correct |
9 |
Correct |
4 ms |
7372 KB |
Output is correct |
10 |
Correct |
4 ms |
7372 KB |
Output is correct |
11 |
Correct |
4 ms |
7364 KB |
Output is correct |
12 |
Correct |
4 ms |
7376 KB |
Output is correct |
13 |
Correct |
5 ms |
7372 KB |
Output is correct |
14 |
Correct |
4 ms |
7372 KB |
Output is correct |
15 |
Correct |
5 ms |
7372 KB |
Output is correct |
16 |
Correct |
4 ms |
7372 KB |
Output is correct |
17 |
Correct |
5 ms |
7372 KB |
Output is correct |
18 |
Correct |
4 ms |
7296 KB |
Output is correct |
19 |
Correct |
4 ms |
7364 KB |
Output is correct |
20 |
Correct |
4 ms |
7244 KB |
Output is correct |
21 |
Correct |
4 ms |
7244 KB |
Output is correct |
22 |
Correct |
5 ms |
7360 KB |
Output is correct |
23 |
Correct |
4 ms |
7244 KB |
Output is correct |
24 |
Correct |
4 ms |
7244 KB |
Output is correct |
25 |
Correct |
4 ms |
7244 KB |
Output is correct |
26 |
Correct |
4 ms |
7244 KB |
Output is correct |
27 |
Correct |
4 ms |
7360 KB |
Output is correct |
28 |
Correct |
4 ms |
7360 KB |
Output is correct |
29 |
Correct |
4 ms |
7360 KB |
Output is correct |
30 |
Correct |
4 ms |
7244 KB |
Output is correct |
31 |
Correct |
4 ms |
7356 KB |
Output is correct |
32 |
Correct |
6 ms |
7360 KB |
Output is correct |
33 |
Correct |
4 ms |
7344 KB |
Output is correct |
34 |
Correct |
4 ms |
7372 KB |
Output is correct |
35 |
Correct |
5 ms |
7372 KB |
Output is correct |
36 |
Correct |
4 ms |
7372 KB |
Output is correct |
37 |
Correct |
5 ms |
7408 KB |
Output is correct |
38 |
Correct |
4 ms |
7372 KB |
Output is correct |
39 |
Correct |
5 ms |
7500 KB |
Output is correct |
40 |
Correct |
5 ms |
7372 KB |
Output is correct |
41 |
Correct |
7 ms |
7404 KB |
Output is correct |
42 |
Correct |
5 ms |
7348 KB |
Output is correct |
43 |
Correct |
7 ms |
7372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7372 KB |
Output is correct |
2 |
Correct |
5 ms |
7372 KB |
Output is correct |
3 |
Correct |
4 ms |
7372 KB |
Output is correct |
4 |
Correct |
5 ms |
7408 KB |
Output is correct |
5 |
Correct |
4 ms |
7372 KB |
Output is correct |
6 |
Correct |
5 ms |
7500 KB |
Output is correct |
7 |
Correct |
5 ms |
7372 KB |
Output is correct |
8 |
Correct |
7 ms |
7404 KB |
Output is correct |
9 |
Correct |
5 ms |
7348 KB |
Output is correct |
10 |
Correct |
7 ms |
7372 KB |
Output is correct |
11 |
Correct |
4 ms |
7244 KB |
Output is correct |
12 |
Correct |
5 ms |
7356 KB |
Output is correct |
13 |
Correct |
4 ms |
7244 KB |
Output is correct |
14 |
Correct |
4 ms |
7372 KB |
Output is correct |
15 |
Correct |
4 ms |
7372 KB |
Output is correct |
16 |
Correct |
4 ms |
7368 KB |
Output is correct |
17 |
Correct |
5 ms |
7524 KB |
Output is correct |
18 |
Correct |
6 ms |
7368 KB |
Output is correct |
19 |
Correct |
4 ms |
7372 KB |
Output is correct |
20 |
Correct |
4 ms |
7372 KB |
Output is correct |
21 |
Correct |
4 ms |
7364 KB |
Output is correct |
22 |
Correct |
4 ms |
7376 KB |
Output is correct |
23 |
Correct |
5 ms |
7372 KB |
Output is correct |
24 |
Correct |
4 ms |
7372 KB |
Output is correct |
25 |
Correct |
5 ms |
7372 KB |
Output is correct |
26 |
Correct |
4 ms |
7372 KB |
Output is correct |
27 |
Correct |
5 ms |
7372 KB |
Output is correct |
28 |
Correct |
4 ms |
7296 KB |
Output is correct |
29 |
Correct |
4 ms |
7364 KB |
Output is correct |
30 |
Correct |
4 ms |
7244 KB |
Output is correct |
31 |
Correct |
4 ms |
7244 KB |
Output is correct |
32 |
Correct |
5 ms |
7360 KB |
Output is correct |
33 |
Correct |
4 ms |
7244 KB |
Output is correct |
34 |
Correct |
4 ms |
7244 KB |
Output is correct |
35 |
Correct |
4 ms |
7244 KB |
Output is correct |
36 |
Correct |
4 ms |
7244 KB |
Output is correct |
37 |
Correct |
4 ms |
7360 KB |
Output is correct |
38 |
Correct |
4 ms |
7360 KB |
Output is correct |
39 |
Correct |
4 ms |
7360 KB |
Output is correct |
40 |
Correct |
4 ms |
7244 KB |
Output is correct |
41 |
Correct |
4 ms |
7356 KB |
Output is correct |
42 |
Correct |
6 ms |
7360 KB |
Output is correct |
43 |
Correct |
4 ms |
7344 KB |
Output is correct |
44 |
Correct |
18 ms |
10812 KB |
Output is correct |
45 |
Correct |
24 ms |
10052 KB |
Output is correct |
46 |
Correct |
34 ms |
10688 KB |
Output is correct |
47 |
Correct |
33 ms |
10680 KB |
Output is correct |
48 |
Correct |
30 ms |
11324 KB |
Output is correct |
49 |
Correct |
23 ms |
11600 KB |
Output is correct |
50 |
Correct |
27 ms |
11444 KB |
Output is correct |
51 |
Correct |
28 ms |
12340 KB |
Output is correct |
52 |
Correct |
29 ms |
10716 KB |
Output is correct |
53 |
Correct |
25 ms |
9284 KB |
Output is correct |
54 |
Correct |
24 ms |
11456 KB |
Output is correct |
55 |
Correct |
24 ms |
11456 KB |
Output is correct |