/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 532.0 KiB
#2 Accepted 215ms 736.0 KiB
#3 Accepted 222ms 916.0 KiB
#4 Accepted 224ms 928.0 KiB
#5 Accepted 252ms 2.305 MiB
#6 Accepted 264ms 2.129 MiB

Code

#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    int t;
    cin >> t;
    vector<int> arr;
    while (t--)
    {
        int n;
        cin >> n;
        arr.push_back(n);
    }
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> mh;

    for (int i = 0; i < arr.size(); i++)
    {
        mh.push(make_pair(arr[i], i));
    }

    int q;
    cin >> q;
    while (q--)
    {
        int x;
        cin >> x;

        pair<int, int> minPair = mh.top();
        int minI = minPair.second;
        cout << minI + 1 << endl;
        arr[minI] = x;
        mh.pop();
        mh.push(make_pair(x, minI));
    }

    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:27:50
Judged At
2024-10-03 13:26:51
Judged By
Score
100
Total Time
264ms
Peak Memory
2.305 MiB