/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 540.0 KiB
#3 Wrong Answer 1ms 712.0 KiB
#4 Time Exceeded ≥2094ms ≥1.75 MiB
#5 Time Exceeded ≥2089ms ≥9.102 MiB
#6 Time Exceeded ≥2010ms ≥5.27 MiB
#7 Wrong Answer 265ms 872.0 KiB
#8 Time Exceeded ≥2033ms ≥5.434 MiB
#9 Time Exceeded ≥2070ms ≥5.383 MiB
#10 Time Exceeded ≥2033ms ≥8.984 MiB
#11 Wrong Answer 21ms 712.0 KiB
#12 Wrong Answer 36ms 788.0 KiB
#13 Wrong Answer 2ms 420.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];
            auto k = s.insert(a[i]);
            auto it = distance(s.begin(), k);
            l[i + 1] = it;
            h[i + 1] = (i - it);
        }
        s.clear();
        for (int i = n - 1; i >= 0; i--) {
            auto k = s.insert(a[i]);
            auto it = distance(s.begin(), k);
            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 17:03:32
Judged At
2024-10-03 17:03:32
Judged By
Score
4
Total Time
≥2094ms
Peak Memory
≥9.102 MiB