/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 28ms 1.18 MiB
#3 Accepted 38ms 1.453 MiB
#4 Accepted 38ms 1.316 MiB
#5 Accepted 157ms 11.438 MiB
#6 Accepted 159ms 11.492 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  map<int,int> aa;
  set<int> aas;
  for(int i=0;i<n;i++){
    cin >> a[i];
    aa[a[i]]=i+1;
    aas.insert(a[i]);
  }
  b = a;
  sort(b.begin(),b.end());
  int q;
  vector<int> c;
  cin >> q;
  int minn = b[0];
  int l = 0;
  for(int i=0;i<q;i++){
    int tt;
    cin >> tt;
    int minValue = *aas.begin();
    c.push_back(aa[minValue]);
    aas.erase(minValue);
    aa.erase(minValue);
    aa[tt]=c.back();
    aas.insert(tt);
  }
  for(int i=0;i<c.size();i++){
    cout << c[i]<<"\n";
  }
}

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 16:54:15
Judged At
2024-11-11 03:13:29
Judged By
Score
100
Total Time
159ms
Peak Memory
11.492 MiB