Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <set>
- #include <map>
- #include <ctime>
- #include <queue>
- #include <cmath>
- #include <stack>
- #include <vector>
- #include <valarray>
- #include <cstdio>
- #include <sstream>
- #include <cstring>
- #include <cstdlib>
- #include <iostream>
- #include <algorithm>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace __gnu_pbds;
- using namespace std;
- typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
- typedef long long ll;
- string text="abcdefghijklmnopqrstuvwxyz";
- const int maxn=1e6+7;
- // .--------------.
- // | Try First One|
- // '--------------'
- // | .--------------.
- // | | |
- // V V |
- // .--------------. |
- // | AC. |<---. |
- // '--------------' | |
- // (True)| |(False) | |
- // .--------' | | |
- // | V | |
- // | .--------------. | |
- // | | Try Again |----' |
- // | '--------------' |
- // | |
- // | .--------------. |
- // '->| Try Next One |-------'
- // '--------------'
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- ordered_set s;
- int n;
- cin>>n;
- int a[n+1];
- for(int i=0;i<n;i++)cin>>a[i];
- s.insert(a[0]);
- int ans=0;
- for(int i=1;i<n;i++){
- s.insert(a[i]);
- ans+=s.size()-(s.order_of_key(a[i]+1));
- }
- cout<<ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement