/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 336.0 KiB
#2 Accepted 173ms 744.0 KiB
#3 Accepted 181ms 880.0 KiB
#4 Accepted 187ms 904.0 KiB
#5 Accepted 236ms 2.332 MiB
#6 Accepted 257ms 2.266 MiB

Code

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
    int N, Q;
    cin >> N;

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    cin >> Q;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> minHeap;
    for (int i = 0; i < N; i++) {
        minHeap.push({A[i], i});
    }

    for (int i = 0; i < Q; i++) {
        int X;
        cin >> X;
        pair<int, int> minPair = minHeap.top();
        minHeap.pop();

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

        A[minPair.second] = X;
        minHeap.push({X, minPair.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 17:00:58
Judged At
2024-10-03 13:24:38
Judged By
Score
100
Total Time
257ms
Peak Memory
2.332 MiB