/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 488.0 KiB
#2 Accepted 189ms 708.0 KiB
#3 Accepted 200ms 996.0 KiB
#4 Accepted 201ms 996.0 KiB
#5 Accepted 255ms 7.207 MiB
#6 Accepted 263ms 7.191 MiB

Code

#include <iostream>
#include <map>
#include <vector>
using namespace std;

#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve() {
    ll n; cin >> n;
    map<ll, ll> value_to_pos;
    for (ll i = 1; i <= n; ++i) {
        ll value; cin >> value;
        value_to_pos[value] = i;
    }

    ll q; cin >> q;
    while (q--) {
        ll x; cin >> x;
        auto min_it = value_to_pos.begin();
        ll min_value = min_it->first;
        ll min_pos = min_it->second;
        cout << min_pos << endl;
        value_to_pos.erase(min_it);
        value_to_pos[x] = min_pos;
    }
}

int main() {
    fast
    ll t = 1;
    while (t--) {
        solve();
    }
    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 17:41:32
Judged At
2024-11-11 03:11:07
Judged By
Score
100
Total Time
263ms
Peak Memory
7.207 MiB