/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 201ms 740.0 KiB
#3 Accepted 208ms 744.0 KiB
#4 Accepted 211ms 836.0 KiB
#5 Accepted 246ms 3.43 MiB
#6 Accepted 255ms 3.43 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-10-03 13:30:05
Judged By
Score
100
Total Time
255ms
Peak Memory
3.43 MiB