/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 436.0 KiB
#2 Wrong Answer 1ms 324.0 KiB
#3 Wrong Answer 1ms 320.0 KiB

Code

/**
 *  written by Binoy Barman .
**/

#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define all(v) v.begin(), v.end()
#define Too_Many_Jobs int tts, tc = 1; cin >> tts; hell: while(tts--)
#define Dark_Lord_Binoy ios_base::sync_with_stdio(false); cin.tie(NULL);

#ifdef LOCAL
#include "debug/whereisit.hpp"
#else
#define dbg(...) 42
#endif
#define int long long

int32_t main() {
Dark_Lord_Binoy
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    Too_Many_Jobs {
        int n;
        cin >> n;
        vector<int> a(n), l(n + 1, 0), h(n + 1, 0), L(n + 1, 0), H(n + 1, 0);
        multiset<int> s;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            s.insert(a[i]);
            auto it = distance(s.begin(), s.find(a[i]));
            l[i + 1] = it;
            h[i + 1] = (i - it);
        }
        s.clear();
        for (int i = n - 1; i >= 0; i--) {
            s.insert(a[i]);
            auto it = distance(s.begin(), s.find(a[i]));
            L[i + 1] = it;
            H[i + 1] = (s.size() - 1 - it);
        }
        int q;
        cin >> q;
        while(q--) {
            int x;
            cin >> x;
            int ans = l[x] * H[x] + h[x] * L[x];
            cout << ans << nl;
        }
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1079 Roy and Query (Easy Version)
Contest
Brain Booster #6
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-03 16:56:10
Judged At
2024-12-17 11:33:47
Judged By
Score
4
Total Time
1ms
Peak Memory
436.0 KiB