/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 66ms 5.188 MiB
#3 Accepted 80ms 5.434 MiB
#4 Accepted 76ms 5.383 MiB
#5 Accepted 107ms 10.477 MiB
#6 Accepted 110ms 10.551 MiB

Code

#include<bits/stdc++.h>
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define ll   long long int
#define all(u) sort(u.begin(),u.end())
#define nxt(u) next_permutation(u.begin(),u.end())
#define rev(u) reverse(u.begin(),u.end())
#define cinv(u) for(auto &it : u) cin >> it;
#define pb push_back
#define Which would be worse
#define siz(st) st.size()
#define nl "\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n";
#define pii  pair < int , int >
#define v vector
#define For(s , e , k) for(int i = s ; i <= e ; i += k)
#define print(s , e , k , ar) for(int i = s ; i <= e ; i += k) cout << ar[i] << " \n"[i == e]
using namespace std;
//#ifndef ONLINE_JUDGE
//#include "template.h"
//#endif
const int fx[]={-1,0,1,0};
const int fy[]={0,1,0,-1};
const int sz = 2e5 + 10 ;
//cout<<"Case "<<t<<": "<<ans<<endl;
//priority_queue <ll, vector<ll>, greater<ll> > pq;//soto theke boro
//cout<<setprecision(10)<<fixed;
// ll id=lower_bound(de.begin(),de.end())-de.begin();
/*remainder extra space*/

void solve(){
      int n ;
      cin >> n ;
     map < int , int > ar ;
      priority_queue < int , vector<int>, greater<int > > pq;
      For(0 , n - 1 , 1){
          int x ;
          cin >> x ;
          ar[x] = i ;
          pq.push(x);
     }
     int q ;
     cin >> q ;
     while(q--){
        int val ;
        cin >> val ;
        int to = pq.top();
       // who(to);
        pq.pop();
        pq.push(val);
        cout << ar[to] + 1 << "\n";
        ar[val] = ar[to];


     }




}
int main(){

     fastio;
     int T = 1;
     //cin >> T;
     while(T--)
     solve();
}

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:59:31
Judged At
2024-11-11 03:16:37
Judged By
Score
100
Total Time
110ms
Peak Memory
10.551 MiB