-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
47 lines (36 loc) · 801 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline void solve() {
int n;
cin >> n;
unordered_set<int> rounds;
for (int i = 0, v; i < n; ++i) {
cin >> v;
if (auto it = rounds.find(v - 1); it != rounds.end()) rounds.erase(it);
rounds.insert(v);
}
cout << rounds.size();
}
inline void solve1() {
int n;
cin >> n;
vector<int> nums(n + 1);
vector<int> indices(n + 1, n + 1);
for (int i = 1; i <= n; ++i) {
cin >> nums[i];
indices[nums[i]] = i;
}
int cnt = 0;
for (int i = 1; i <= n; ++i) {
int v = nums[i];
if (indices[v - 1] > indices[v]) ++cnt;
}
cout << cnt;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}