Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- int n, q;
- cin >> n >> q;
- int niza[n];
- int idx[55];
- for(int i = 1; i <= 50; i++) {
- idx[i] = 0;
- }
- for(int i = 0; i < n; i++) {
- cin >> niza[i];
- if(idx[niza[i]] == 0) {
- idx[niza[i]] = i + 1;
- }
- }
- for(int i = 0; i < q; i++) {
- int x;
- cin >> x;
- cout << idx[x] << " ";
- for(int j = 1; j <= 50; j++) {
- if(idx[j] < idx[x] and idx[j] != 0) {
- idx[j]++;
- }
- }
- idx[x] = 1;
- }
- return 0;
- }
- //n = 27 - 4 = 23
- // 89 145 42 20 4 16 37 58
- // 23 % 8 = 7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement