Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- STARK_BOY
- */
- #include <bits/stdc++.h>
- #include <fstream>
- using namespace std;
- #define rep(i,a,b) for(ll i=a;i<b;i++)
- #define F first
- #define S second
- typedef long long ll;
- typedef vector< ll > vi;
- #include<ext/pb_ds/assoc_container.hpp>
- #include<ext/pb_ds/tree_policy.hpp>
- using namespace __gnu_pbds;
- template<typename T>
- using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
- int main()
- {
- int ti=1;
- //cin>>ti;
- while(ti--)
- {
- ll n;
- cin>>n;
- vi ar(n);
- rep(i,0,n)cin>>ar[i];
- map<ll,ll> ma;
- ordered_set<pair<ll,ll>> se;
- ll ans=0;
- for(ll i=n-1;i>=0;i--)
- {
- pair<ll,ll> p=make_pair(ar[i],0);
- ans+=se.order_of_key(p);
- ma[ar[i]]++;
- se.insert(make_pair(ar[i],ma[ar[i]]));
- }
- cout<<ans;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement