Guest User

Untitled

a guest
Jan 20th, 2024
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
  3. using namespace std;
  4. typedef long long ll;
  5. int main() {
  6.     FastIO;
  7.     ll i, c, ans, N;
  8.     cin >> N;
  9.     vector<ll> A(N);
  10.     for(i = 0; i < N; i++)
  11.         cin >> A[i];
  12.     map<ll, ll> ew;
  13.     for(i = 0; i < N; i++) {
  14.         auto b = ew.lower_bound(A[i]);
  15.         c = 1;
  16.         for(auto it = ew.begin(); it != b; it++)
  17.             c += it->second;
  18.         if(ew.find(A[i]) == ew.end())
  19.             ew[A[i]] = 0;
  20.         ew[A[i]] += c;
  21.     }
  22.     ans = 1;
  23.     for(const auto &x : ew)
  24.         ans += x.second;
  25.     cout << ans << '\n';
  26.     return 0;
  27. }
  28.  
Add Comment
Please, Sign In to add comment