Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace __gnu_pbds;
- #define cin(v) for (auto &i : v) cin >> i;
- #define cout(v) for (auto &i : v) cout << i << " "; cout<<'\n';
- #define ll long long
- #define all(v) v.begin(), v.end()
- #define rall(v) v.rbegin(), v.rend()
- #define MOD 1000000007
- #define Ceil(a,b) a / b + (a % b != 0)
- #define Time cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " Secs"<< "\n";
- #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
- #define multi_ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
- void Warding()
- {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- /*
- STOP USING int
- */
- void solve(){
- int n; cin>>n;
- vector<int> v(n);
- deque<int> ans;
- multi_ordered_set st;
- for(int i=0; i < n; i++){
- cin>>v[i];
- }
- st.insert(v[n-1]);
- for(int i=n-2; i>=0; i--){
- ans.push_front(st.size() - st.order_of_key(v[i] + 1));
- st.insert(v[i]);
- }
- ans.push_back(0);
- cout(ans);
- }
- int main()
- {
- Warding();
- int TC = 1;
- // cin >> TC;
- while (TC--)
- {
- solve();
- }
- Time
- }
Add Comment
Please, Sign In to add comment