/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 216ms 608.0 KiB
#3 Accepted 223ms 928.0 KiB
#4 Accepted 210ms 896.0 KiB
#5 Accepted 253ms 2.352 MiB
#6 Accepted 261ms 2.289 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-11-11 03:14:41
Judged By
Score
100
Total Time
261ms
Peak Memory
2.352 MiB