/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 193ms 720.0 KiB
#3 Accepted 199ms 1000.0 KiB
#4 Accepted 196ms 956.0 KiB
#5 Accepted 255ms 7.223 MiB
#6 Accepted 251ms 7.133 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-10-03 13:21:09
Judged By
Score
100
Total Time
255ms
Peak Memory
7.223 MiB