/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 20ms 532.0 KiB
#3 Accepted 24ms 836.0 KiB
#4 Accepted 26ms 944.0 KiB
#5 Accepted 71ms 7.898 MiB
#6 Accepted 83ms 7.844 MiB

Code

#include<bits/stdc++.h>
using namespace std;

#define print(a) for(auto x:a)cout<<x<<' ';cout<<'\n';
#define debug(x) cout<<#x<<" "<<x<<'\n'
#define int   long long int

const int M = 1e9 + 7;
const int N = 2e5 + 10;

void solve(){
      int n; cin >> n;
      vector<int> a(n);
      set<pair<int,int>> st;

      for(int i = 0; i < n; i++){
         cin >> a[i];
         st.insert({a[i], i});
      }
      int q; cin >> q;

      while(q--){
         int x; cin >> x;
         pair<int,int> p = *st.begin();
         st.erase(st.begin());
         cout << p.second + 1 <<'\n';
         a[p.second] = x;
         st.insert({a[p.second], p.second});
      }

}

signed main() {
   ios_base::sync_with_stdio (0);
   cin.tie (0);

   int t = 1;  // cin >> t;
   for (int tc = 1; tc <= t; tc++) {
      //cout<<"Case "<<tc<<": ";
      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:38:17
Judged At
2024-08-16 15:38:17
Judged By
Score
100
Total Time
83ms
Peak Memory
7.898 MiB