/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 219ms 728.0 KiB
#3 Accepted 226ms 892.0 KiB
#4 Accepted 227ms 816.0 KiB
#5 Accepted 267ms 2.312 MiB
#6 Accepted 270ms 2.188 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-11-11 03:13:09
Judged By
Score
100
Total Time
270ms
Peak Memory
2.312 MiB