/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 512.0 KiB
#2 Accepted 216ms 728.0 KiB
#3 Accepted 222ms 920.0 KiB
#4 Accepted 220ms 852.0 KiB
#5 Accepted 257ms 2.297 MiB
#6 Accepted 261ms 2.332 MiB

Code


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

typedef pair<int, int> pii;

int main() {
    int n;
    cin >> n;

    vector<int> a(n);
    priority_queue<pii, vector<pii>, greater<pii>> minHeap;

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        minHeap.push({a[i], i});
    }

    int q;
    cin >> q;

    for (int i = 0; i < q; ++i) {
        int x;
        cin >> x;

        
        while (minHeap.top().first != a[minHeap.top().second]) {
            minHeap.pop();
        }

        pii minElement = minHeap.top();
        minHeap.pop();

       
        cout << minElement.second + 1 << endl;

        
        a[minElement.second] = x;

        
        minHeap.push({x, minElement.second});
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1086 KuZ the Position
Contest
Bangladesh 2.0
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-16 16:47:11
Judged At
2024-10-03 13:25:58
Judged By
Score
100
Total Time
261ms
Peak Memory
2.332 MiB