/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 222ms 704.0 KiB
#3 Accepted 245ms 852.0 KiB
#4 Accepted 287ms 960.0 KiB
#5 Accepted 372ms 5.996 MiB
#6 Accepted 374ms 6.047 MiB

Code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int n;
    cin>>n;
    vector<int> arr(n);
    set<pair<int,int>> s;  
    
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        s.insert({arr[i], i}); 
    }

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

        auto minElem=*s.begin();  
        int minPos=minElem.second;

        cout << minPos + 1 << endl;  

        s.erase(s.begin());
        s.insert({x, minPos});
        arr[minPos] = x;
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1086 KuZ the Position
Contest
Bangladesh 2.0
Language
C++17 (G++ 13.2.0)
Submit At
2024-08-16 16:15:30
Judged At
2024-11-11 03:15:23
Judged By
Score
100
Total Time
374ms
Peak Memory
6.047 MiB