/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 316.0 KiB
#2 Accepted 19ms 648.0 KiB
#3 Accepted 25ms 1012.0 KiB
#4 Accepted 25ms 768.0 KiB
#5 Accepted 79ms 7.988 MiB
#6 Accepted 82ms 7.801 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-10-03 13:30:53
Judged By
Score
100
Total Time
82ms
Peak Memory
7.988 MiB