Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
- using namespace std;
- typedef long long ll;
- int main() {
- FastIO;
- ll i, c, ans, N;
- cin >> N;
- vector<ll> A(N);
- for(i = 0; i < N; i++)
- cin >> A[i];
- map<ll, ll> ew;
- for(i = 0; i < N; i++) {
- auto b = ew.lower_bound(A[i]);
- c = 1;
- for(auto it = ew.begin(); it != b; it++)
- c += it->second;
- if(ew.find(A[i]) == ew.end())
- ew[A[i]] = 0;
- ew[A[i]] += c;
- }
- ans = 1;
- for(const auto &x : ew)
- ans += x.second;
- cout << ans << '\n';
- return 0;
- }
Add Comment
Please, Sign In to add comment