/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 212ms 640.0 KiB
#3 Accepted 210ms 932.0 KiB
#4 Accepted 215ms 900.0 KiB
#5 Accepted 253ms 3.492 MiB
#6 Accepted 271ms 3.516 MiB

Code

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

signed main() {
    int n, q;
    cin >> n;
    
    vector<int> vl(n);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;

    for (int i = 0; i < n; ++i) {
        cin >> vl[i];
        pq.push({vl[i], i});
    }
    
    cin >> q;
    while (q--) {
        int x;
        cin >> x;
        
        while (!pq.empty() && pq.top().first != vl[pq.top().second]) {
            pq.pop();
        }
        
        int min_idx = pq.top().second;
        cout << (min_idx + 1) << endl;
        
        vl[min_idx] = x;
        pq.push({x, min_idx});
    }
    
    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 15:45:20
Judged At
2024-11-11 03:17:33
Judged By
Score
100
Total Time
271ms
Peak Memory
3.516 MiB