some dp problems

This commit is contained in:
2024-06-14 19:49:10 +02:00
parent 66d059f230
commit b67bf7bbea
21 changed files with 124 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
// Collecting Numbers
#include<bits/stdc++.h>
using namespace std;
int main() {
int n; cin >> n;
vector<int> in(n);
for (auto &e: in) cin >> e;
int count = 1;
map<int, int> pos;
for (int i{}; i < n; i++) pos[in[i]] = i;
for (int i = 1; i < n; i++) {
if (pos[i] > pos[i+1]) count ++;
}
cout << count << endl;
return 0;
}