/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 536.0 KiB
#2 Accepted 217ms 704.0 KiB
#3 Accepted 214ms 720.0 KiB
#4 Accepted 220ms 932.0 KiB
#5 Accepted 263ms 3.422 MiB
#6 Accepted 262ms 3.5 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-11-11 03:16:10
Judged By
Score
100
Total Time
263ms
Peak Memory
3.5 MiB