Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define rep(i, a, b) for(int i = (a); i < (b); ++i)
  5. #define trav(a, x) for(auto& a : x)
  6. #define all(x) begin(x), end(x)
  7. #define sz(x) (int)(x).size()
  8. #define pb push_back
  9. #define fst first
  10. #define snd second
  11.  
  12. typedef long long ll;
  13. typedef long double ld;
  14. typedef pair<ll, ll> pii;
  15. typedef vector<ll> vi;
  16. typedef vector<vi> vvi;
  17. typedef vector<pii> vii;
  18.  
  19. int main() {
  20. cin.sync_with_stdio(0); cin.tie(0);
  21. cin.exceptions(cin.failbit);
  22.  
  23. int n;
  24. cin >> n;
  25.  
  26. vi a(n);
  27. rep(i,0,n) cin >> a[i];
  28.  
  29. multiset<int> arr;
  30. rep(i,0,n) {
  31. auto it= arr.lower_bound(a[i]);
  32. if (it != arr.end() and *it == a[i]) {
  33. arr.erase(it);
  34. }
  35. arr.insert(a[i]-1);
  36. }
  37.  
  38. cout << sz(arr) << endl;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement