/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 209ms 680.0 KiB
#3 Accepted 214ms 912.0 KiB
#4 Accepted 214ms 836.0 KiB
#5 Accepted 246ms 3.406 MiB
#6 Accepted 262ms 3.508 MiB

Code

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long long> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<>> minHeap;
    for (int i = 0; i < n; i++) {
        minHeap.push({arr[i], i});
    }

    int m;
    cin >> m;

    while (m--) {
        long long temp;
        cin >> temp;

        while (!minHeap.empty() && minHeap.top().second < 0) {
            minHeap.pop();
        }

        if (!minHeap.empty()) {
            long long minVal = minHeap.top().first;
            int pos = minHeap.top().second;
            cout << pos + 1 << endl;

            minHeap.pop();
            minHeap.push({temp, pos});
        }
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1086 KuZ the Position
Contest
Bangladesh 2.0
Language
C++17 (G++ 13.2.0)
Submit At
2024-08-16 16:05:46
Judged At
2024-10-03 13:28:43
Judged By
Score
100
Total Time
262ms
Peak Memory
3.508 MiB