/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 194ms 740.0 KiB
#3 Accepted 200ms 936.0 KiB
#4 Accepted 202ms 960.0 KiB
#5 Accepted 302ms 6.035 MiB
#6 Accepted 323ms 6.031 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-10-03 13:27:54
Judged By
Score
100
Total Time
323ms
Peak Memory
6.035 MiB