/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 185ms 748.0 KiB
#3 Accepted 191ms 952.0 KiB
#4 Accepted 190ms 908.0 KiB
#5 Accepted 199ms 3.527 MiB
#6 Accepted 207ms 3.539 MiB

Code

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define all(v) (v).begin(), (v).end()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define F first 
#define S second

const ll M = 1e18 + 7;
const int N = 1e5 + 7;
const int MOD = 1e9 + 7;



void Hrid_solve(){
    int n;
    cin >> n;
    vector<ll> v(n);
    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> pq;
    for(ll i = 0; i < n; i++) {
        cin >> v[i];
        pq.push({v[i],-(i+1)});
    }

    int q;
    cin >> q;

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

        auto p = pq.top();
        ll val = p.first;
        ll ind = p.second*(-1);
        pq.pop();
        pq.push({x,ind*-1});

        cout << ind << endl;
    }
    
}


/* ************** What defines us is how well we rise after we Fall !! ************** */

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    int tc = 1;
    // cin >> tc;
    for(int kase = 1; kase <= tc; kase++){
        // cout << "Case " << kase << ": ";
        Hrid_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 15:49:09
Judged At
2024-11-11 03:17:12
Judged By
Score
100
Total Time
207ms
Peak Memory
3.539 MiB